Html 输入光标颜色
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2746011/
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
Input cursor color
提问by eomeroff
How to change the color of content in HTML input type text while entering some value. And also the cursor color when it has focus.
如何在输入某个值时更改 HTML 输入类型文本中内容的颜色。以及光标具有焦点时的颜色。
回答by Pekka
Changing the colour when entering content is easy:
输入内容时更改颜色很容易:
input:focus { color: yellow }
not supported by IE7 and lower. Compatibility table here.
IE7 及更低版本不支持。兼容性表在这里。
Changing the cursor colour specifically is impossible as far as I know. It will usually take on the text content's colour which should be fine in most cases.
据我所知,具体更改光标颜色是不可能的。它通常采用文本内容的颜色,在大多数情况下应该没问题。
回答by sealocal
Use color
to specify the text color. Use caret-color
to specify the caret's color.
使用color
指定的文本颜色。使用caret-color
指定插入符号的颜色。
HTML
HTML
<input class="examples" />
<textarea class="examples"></textarea>
CSS
CSS
.examples {
color: gray;
caret-color: red;
}
回答by Gibolt
Use modern CSS!
使用现代 CSS!
input {
caret-color : red;
}
input:focus {
color : yellow;
}