Change an HTML5 input's placeholder color with CSS

后端 未结 30 3164
猫巷女王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 05:03

    You can use this for input and focus style:

    input::-webkit-input-placeholder  { color:#666;}
    input:-moz-placeholder  { color:#666;}
    input::-moz-placeholder { color:#666;}
    input:-ms-input-placeholder  { color:#666;}
    /* focus */
    input:focus::-webkit-input-placeholder { color:#eee; }
    input:focus:-moz-placeholder { color:#eee } /* FF 4-18 */
    input:focus::-moz-placeholder { color:#eee } /* FF 19+ */
    input:focus:-ms-input-placeholder { color:#eee } /* IE 10+ */
    

提交回复
热议问题