Change an HTML5 input's placeholder color with CSS

后端 未结 30 3183
猫巷女王i
猫巷女王i 2020-11-21 04:36

Chrome supports the placeholder attribute on input[type=text] elements (others probably do too).

But the following CSS doesn\'t do anything

30条回答
  •  一整个雨季
    2020-11-21 04:46

    If you are using Bootstrap and couldn't get this working then probably you missed the fact that Bootstrap itself adds these selectors. This is Bootstrap v3.3 we are talking about.

    If you are trying to change the placeholder inside a .form-control CSS class then you should override it like this:

    .form-control::-webkit-input-placeholder { /* WebKit, Blink, Edge */
        color:    #777;
    }
    .form-control:-moz-placeholder { /* Mozilla Firefox 4 to 18 */
        color:    #777;
        opacity:  1;
    }
    .form-control::-moz-placeholder { /* Mozilla Firefox 19+ */
        color:    #777;
        opacity:  1;
    }
    .form-control:-ms-input-placeholder { /* Internet Explorer 10-11 */
        color:    #777;
    }
    

提交回复
热议问题