问题
How can I change the Placeholder Color in Bootstrap?
The following code, which I tried, doesn't work.
input::-webkit-input-placeholder {
color: red;
}
input:-moz-placeholder {
color: red;
}
回答1:
.form-control::placeholder { /* Chrome, Firefox, Opera, Safari 10.1+ */
color: red;
opacity: 1; /* Firefox */
}
.form-control:-ms-input-placeholder { /* Internet Explorer 10-11 */
color: red;
}
.form-control::-ms-input-placeholder { /* Microsoft Edge */
color: red;
}
The following is the reference link. https://www.w3schools.com/howto/howto_css_placeholder.asp
回答2:
In Bootstrap 4 you change it like this:
.form-control::-webkit-input-placeholder {
color: red;
}
回答3:
For Bootstrap 4, if you're using SCSS, just override variable $input-placeholder-color
before you import bootstrap.
// variable overrides
$input-placeholder-color: red;
// Bootstrap and its default variables
@import "../node_modules/bootstrap/scss/bootstrap";
来源:https://stackoverflow.com/questions/51299051/placeholder-color-change-in-bootstrap