CSS样式占位符文本 [英] CSS styling placeholder text

查看:378
本文介绍了CSS样式占位符文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试设置占位符文本的样式,但似乎无法选择它。如果我输入的是:

I am trying to style placeholder text, but I can't seem to select it. If my input is this:

<input id="search" class="search-query" placeholder="Placeholder text here" name="" value"">

如何在css中选择占位符文本进行样式设计?

How can I select the placeholder text in css for styling?

推荐答案

::-webkit-input-placeholder {
   color: red;
}

:-moz-placeholder { /* Firefox 18- */
   color: red;  
}

::-moz-placeholder {  /* Firefox 19+ */
   color: red;  
}

:-ms-input-placeholder {  
   color: red;  
}

/* All modern browsers except IE and EDGE */
::placeholder { color: red }

演示: http://jsfiddle.net/DLGFK/

这篇关于CSS样式占位符文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆