CSS输入字段输入文本的文本颜色 [英] CSS Input field text color of inputted text
问题描述
我有一个输入字段,其中的文本的颜色是黑色的。 (我正在使用jquery.placeholder)让我们说,文本中有电子邮件
当你点击这个字段,黑色占位文本消失到jquery.placeholder)。
输入到此字段的任何文本,我希望它变为红色,当您取消选择此字段时,我希望它保持红色。 / p>
目前,电子邮件的文本是黑色的,我键入的内容是红色的,这是伟大的,但一旦我取消选择,它去回到黑色。谁能帮助我?我想让文字保持红色,即使它被取消选择。这是我的代码
textarea:focus,input:focus {
color:#ff0000;
}
input,select,textarea {
color:#000;
}
Thankyou!
将您的第二个样式更改为:
input,select,textarea {
color:#ff0000;
}
目前,您要告诉表单将文本更改为 black
。上面的补救办法。
此外,将正常状态样式放在:focus
和:hover
样式。这有助于防止这个问题。所以
输入,选择,textarea {
color:#ff0000;
}
textarea:focus,input:focus {
color:#ff0000;
}
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"
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;
}
Thankyou!
Change your second style to this:
input, select, textarea{
color: #ff0000;
}
At the moment, you are telling the form to change the text to black
once the focus is off. The above remedies that.
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屋!