Change an HTML5 input's placeholder color with CSS

后端 未结 30 3079
猫巷女王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:58

    For Bootstrap users, if you are using class="form-control", there may be a CSS specificity issue. You should get a higher priority:

    .form-control::-webkit-input-placeholder {
        color: red;
    }
    //.. and other browsers
    

    Or if you are using Less:

    .form-control{
        .placeholder(red);
    }
    

提交回复
热议问题