Change an HTML5 input's placeholder color with CSS

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

    I think this code will work because a placeholder is needed only for input type text. So this one line CSS will be enough for your need:

    input[type="text"]::-webkit-input-placeholder {
        color: red;
    }
    

提交回复
热议问题