如何更改焦点上的占位符颜色? [英] How to change placeholder color on focus?
本文介绍了如何更改焦点上的占位符颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在聚焦输入字段时更改占位符的颜色?
我使用这个CSS设置默认颜色,但如何改变它的焦点?
How to change the color of placeholder when focus the input field? I use this css to set the default color, but how to change it on focus?
::-webkit-input-placeholder { color: #999; }
/* Firefox < 19 */
:-moz-placeholder { color: #999; }
/* Firefox > 19 */
::-moz-placeholder { color: #999; }
/* Internet Explorer 10 */
:-ms-input-placeholder { color: #999; }
推荐答案
>
Try this, this should work :
input::-webkit-input-placeholder {
color: #999;
}
input:focus::-webkit-input-placeholder {
color: red;
}
/* Firefox < 19 */
input:-moz-placeholder {
color: #999;
}
input:focus:-moz-placeholder {
color: red;
}
/* Firefox > 19 */
input::-moz-placeholder {
color: #999;
}
input:focus::-moz-placeholder {
color: red;
}
/* Internet Explorer 10 */
input:-ms-input-placeholder {
color: #999;
}
input:focus:-ms-input-placeholder {
color: red;
}
下面是一个示例: http://jsfiddle.net/XDutj/27/
这篇关于如何更改焦点上的占位符颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文