Change an HTML5 input's placeholder color with CSS

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

    In Firefox and Internet Explorer, the normal input text color overrides the color property of placeholders. So, we need to

    ::-webkit-input-placeholder { 
        color: red; text-overflow: ellipsis; 
    }
    :-moz-placeholder { 
        color: #acacac !important; text-overflow: ellipsis; 
    }
    ::-moz-placeholder { 
        color: #acacac !important; text-overflow: ellipsis; 
    } /* For the future */
    :-ms-input-placeholder { 
        color: #acacac !important; text-overflow: ellipsis; 
    }
    

提交回复
热议问题