Change sweetalert placeholder color with css

余生长醉 提交于 2019-12-12 04:21:31

问题


I have a Sweetalert as follows:

swal({
                                               title: "my title",
                                               text: "",
                                               type: "input",
                                               imageUrl: "images/my_image.png",
                                               showCancelButton: true,
                                               closeOnConfirm: false,
                                               animation: "slide-from-top",
                                               inputPlaceholder: "username..."
                                               },
                                               function(inputValue){
                                               if (inputValue === false) return false;
                                               if (inputValue === "") {
                                               swal.showInputError("you didn't type anything...");
                                               return false
                                               }
                                               });

How can I change the color of the inputPlaceholder that appears in the sweetalert. I have tried:

.sweet-alert input::-webkit-input-placeholder { /* Chrome/Opera/Safari */
    color: whitesmoke;
    padding-left: 4px;
}
.sweet-alert input::-moz-placeholder { /* Firefox 19+ */
    color: whitesmoke;
    padding-left: 4px;
}
.sweet-alert input:-ms-input-placeholder { /* IE 10+ */
    color: whitesmoke;
    padding-left: 4px;
}
.sweet-alert input:-moz-placeholder { /* Firefox 18- */
    color: whitesmoke;
    padding-left: 4px;
}
.inputPlaceholder {
    color: white !important;
}

回答1:


Found the solution. In sweetalert.css file there are these lines related to the placehodler:

.sweet-alert input:focus::-moz-placeholder {
        transition: opacity 0.3s 0.03s ease;
        opacity: 0.9; }
      .sweet-alert input:focus:-ms-input-placeholder {
        transition: opacity 0.3s 0.03s ease;
        opacity: 0.9; }
      .sweet-alert input:focus::-webkit-input-placeholder {
        transition: opacity 0.3s 0.03s ease;
        opacity: 0.9; }
    .sweet-alert input::-moz-placeholder {
      color: whitesmoke; }
    .sweet-alert input:-ms-input-placeholder {
      color: whitesmoke; }
    .sweet-alert input::-webkit-input-placeholder {
      color: whitesmoke; }

Just had to change the opacities and the colors.



来源:https://stackoverflow.com/questions/41644424/change-sweetalert-placeholder-color-with-css

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!