输入文本的 CSS 输入字段文本颜色 [英] CSS Input field text color of inputted text
问题描述
我有一个输入框,里面的文字颜色是黑色的.(我正在使用 jquery.placeholder)假设那里的文字是电子邮件"
I have an input field, and the color of the text in it is black. (I'm using jquery.placeholder) Let's say the text in there is "E-Mail"
当您单击此字段时,黑色占位文本会消失(感谢 jquery.placeholder).
When you click on this field, the black placeholding text dissapears (thanks to jquery.placeholder).
输入到该字段的任何文本,我希望它变成红色,当您取消选择该字段时,我希望它保持红色.
Any text inputted into this field, I want it to turn red, and when you deselect this field, I want it to stay red.
目前,电子邮件"文本是黑色的,我输入的任何内容都是红色的,这很好,但是一旦我取消选择,它就会变回黑色.谁能帮我?我希望文本保持红色,即使在取消选择之后也是如此.这是我的代码
At the moment, the text saying "E-Mail" is black, and anything I type into is red, which is great, but as soon as i deselect, it goes back to black. Can anyone help me? I want the text to stay red, even after it's deselected. Here is my code
textarea:focus, input:focus {
color: #ff0000;
}
input, select, textarea{
color: #000;
}
推荐答案
将您的第二个样式更改为:
Change your second style to this:
input, select, textarea{
color: #ff0000;
}
目前,您正在告诉表单,一旦焦点关闭,将文本更改为 black
.以上补救措施.
At the moment, you are telling the form to change the text to black
once the focus is off. The above remedies that.
此外,在样式表中将正常状态样式置于 :focus
和 :hover
样式之前也是一个好主意.这有助于防止这个问题.所以
Also, it is a good idea to place the normal state styles ahead of the :focus
and :hover
styles in your stylesheet. That helps prevent this problem. So
input, select, textarea{
color: #ff0000;
}
textarea:focus, input:focus {
color: #ff0000;
}
这篇关于输入文本的 CSS 输入字段文本颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!