【发布时间】:2014-08-23 17:58:55
【问题描述】:
如何在不影响 Internet Explorer 11 中 placeholder 字体颜色的情况下更改 input 文本 框的字体颜色?
如果我更改输入中字体的颜色 (Fiddle):
HTML:
<div class="buttonToolbar">
<input type="text" placeholder="e.g. Stackoverflow"><br>
</div>
CSS:
.buttonToolbar input {
color: Blue;
}
:-ms-input-placeholder { /* Internet Explorer 10+ */
font-style: italic;
color: GrayText;
}
::-webkit-input-placeholder { /* WebKit browsers */
font-style: italic;
color: GrayText;
}
占位符文本不再是 Internet Explorer 11 中的默认灰色:
但它确实可以在 Chrome 35 中显示:
奖金聊天
如果我不对input 框设置样式,则输入框没有设置样式。改变:
.buttonToolbar input {
color: Blue;
}
到
.buttonToolbar {
color: Blue;
}
表示占位符文本现在执行它应该做的事情:
但是现在文本颜色没有做它应该做的事情:
我需要弄清楚如何使用 CSS 更改输入的 HTML5 占位符颜色。
阅读奖励
【问题讨论】:
-
这听起来很傻,但是.. 你有一个元标签来声明用户进入页面时会遇到的 IE 版本吗? IE
<meta http-equiv="X-UA-Compatible" content="IE=edge">会给你最新的 IE,我知道 IE 8/9 显示 HTML5 属性有困难。 -
@BuddhistBeast 是的。您也可以在 fiddler 页面上确认 IE 处于 "Edge" 模式。
标签: css html internet-explorer-11