问题
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