CSS 将输入占位符颜色更改为更深

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15497550/
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-29 22:06:15  来源:igfitidea点击:

Change input placeholder color darker

cssinputtextareaplaceholder

提问by Phuc Pham

Follow this article (Style text input placeholder), i can change the color of the text input placeholder to red color. But it is always a light-red color, not red exactly.

按照这篇文章(样式文本输入占位符),我可以将文本输入占位符的颜色更改为红色。但它始终是浅红色,而不是完全红色。

Is there any way to make it a red color exactly?

有什么办法可以使它完全变成红色?

update

更新

The color on Chrome is red (this is correct), the color on Firefox is not red, it is light-red or blurred, i guessed that.

Chrome 上的颜色是红色(这是正确的),Firefox 上的颜色不是红色,而是浅红色或模糊,我猜是这样。

http://i279.photobucket.com/albums/kk132/svincoll4/2013-03-19_181239_zps84166305.png

http://i279.photobucket.com/albums/kk132/svincoll4/2013-03-19_181239_zps84166305.png



EDIT (from the OP answer):

编辑(来自 OP 答案):

Please check this example (http://jsfiddle.net/LQkQG/), the color is red on Chrome, but light-redon Firefox. I want the color on Firefox same with the Chrome.

请检查此示例(http://jsfiddle.net/LQkQG/),Chrome 上的颜色为红色,但light-red在 Firefox 上。我希望 Firefox 上的颜色与 Chrome 相同。

回答by Doug

I've found you need to override opacity.

我发现你需要覆盖不透明度。

::-webkit-input-placeholder { /* WebKit browsers */
    color:    red;
     opacity: 1 !important;
}

回答by Timothy Groote

Yes, by setting its value through HEX (hexadecimal) you get better control of what color to use. The color for bright red (as red as it gets) is #FF0000

是的,通过 HEX(十六进制)设置它的值,您可以更好地控制要使用的颜色。鲜红色(尽可能红)的颜色是#FF0000

Firefox, however is a rebel needs to be told what opacity to use.

然而,Firefox 是一个反叛者,需要被告知使用什么不透明度。

For reference take a look at this chart

作为参考,请看一下这张图表

::-webkit-input-placeholder {
    color: #FF0000;
    opacity: 1 !important; /* for older chrome versions. may no longer apply. */
}

:-moz-placeholder { /* Firefox 18- */
    color: #FF0000;
    opacity: 1 !important;
}

::-moz-placeholder {  /* Firefox 19+ */
    color: #FF0000;
    opacity: 1 !important;
}

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

回答by Sami N

Input a hexidecimal value for the color.

输入颜色的十六进制值。

Maybe use a tool like http://www.colorpicker.com/?

也许使用像http://www.colorpicker.com/这样的工具?

回答by Nikunj Jagad

visit: http://www.w3schools.com/html/html_colors.asp

访问:http: //www.w3schools.com/html/html_colors.asp

<html>
<head>
<style type="text/css">

    input, textarea { color: #000; }
    .placeholder { color: #aaa; }
</style>
</head>
<body>
<form action="" method="post">

            <input type="text" name="user" placeholder="enter a text" />
            <input type="submit" value="submit" onclick="test()" />
</form>

in the place of color code you can write which ever color you want

在颜色代码的地方你可以写你想要的任何颜色