Placeholder Color Change in Bootstrap

╄→гoц情女王★ 提交于 2021-02-07 17:03:15

问题


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

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