css - Firefox 上的占位符文本颜色

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19621306/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 00:51:01  来源:igfitidea点击:

css - placeholder text color on firefox

css

提问by t q

I have a placeholdertext inside an inputform field that i can'tseem to change color to white, it comes out as greybut only on firefox. Chrome browser seems to be fine.

我有一个placeholder内部的文本input窗体字段,我不能似乎改变颜色white,它出来的grey,但只有在Firefox。Chrome浏览器似乎没问题。

When you type into the field the correct color displays, its just the initial placeholderthat is not responsive.

当您在字段中输入正确的颜色时,它只是placeholder没有响应的初始颜色。

Any help will be appreciated please, thank you.

任何帮助将不胜感激,谢谢。

css:

css:

input#myinput::-webkit-input-placeholder {
    color:#FFF; background-color:#CCC; 
}
input#myinput::-moz-placeholder { 
    color:#FFF; background-color:#CCC;  
}
input#myinput:-moz-placeholder { 
    color:#FFF; background-color:#CCC; 
}
input#myinput::-ms-input-placeholder { 
    color:#FFF; background-color:#CCC; 
}   /* IE10+ */

input[type="text"]{
    width:170px; height:16px; padding:12px 5px; border:none; 
    color:#FFF; font:14px/14px 'Arial', Helvetica, sans-serif; 
    text-align:center; background-color:#CCC;
}

Heres my fiddle

这是我的小提琴

回答by Fabrício Matté

Add opacity: 1to the Firefox placeholders.

添加opacity: 1到 Firefox 占位符。

See updated fiddle

查看更新的小提琴

回答by DevWL

//PLACEHOLDER EXAMPLE

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

回答by Ilja

Try

尝试

::-webkit-input-placeholder {
   color: #fff;
}

:-moz-placeholder { /* Firefox 18- */
   color: #fff;  
}

::-moz-placeholder {  /* Firefox 19+ */
   color: #fff;  
}

:-ms-input-placeholder {  
   color: #fff;  
}