如何更改禁用的 SELECT 元素的字体颜色? (在 Firefox 中有效,但在 IE 中无效)
如何更改 IE 中禁用的 SELECT 元素的字体颜色?无论我尝试什么,它仍然是灰色的。我能够将背景从灰色更改为白色,但禁用的 SELECT 内的文本保持不变。对于 Firefox 来说完美的效果对于 IE 中的字体颜色没有影响(在本例中是 IE8)。您可以在这里查看两种浏览器的最新情况:
http://www.flickr.com /photos/64416865@N00/4732813702/
我使用 jQuery 禁用选择元素:
$(selectObject).attr('disabled', 'disabled');
这是我用于禁用选择的 CSS 类:
select[disabled] {
color: black;
background-color: white;
border-style: solid;
}
我发现很奇怪,我可以轻松更改默认背景颜色禁用选择但不选择默认字体颜色。对此有什么建议或想法吗? (或者在 IE 中使用 CSS 完全不可能做到这一点?)
How can I change the font color of a disabled SELECT element in IE? No matter what I tried it stays gray. I was able to change the background from gray to white but the text inside the disabled SELECT stays the same. What works perfectly for Firefox has no effect in terms of font color in IE (in this case IE8). You can see the latest situation for both browsers here:
http://www.flickr.com/photos/64416865@N00/4732813702/
I use jQuery to disable the select element:
$(selectObject).attr('disabled', 'disabled');
and here is the CSS class that I use for disabled selects:
select[disabled] {
color: black;
background-color: white;
border-style: solid;
}
I find it very strange that I could easily change the default background color of disabled selects but not the default font color. Any tips or ideas about this? (Or is this completely impossible in IE by using CSS?)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这在当前的IE中可能是不可能做到的。未来的浏览器可能会支持 :disabled 伪类(请参阅 http://www.w3.org/Style/CSS/Test/CSS3/Selectors/current/html/full/flat/css3-modsel-24.html)
It might be impossible to do in current IEs. Browsers to come will probably support a :disabled pseudo-class (see http://www.w3.org/Style/CSS/Test/CSS3/Selectors/current/html/full/flat/css3-modsel-24.html )
编辑:你必须为大多数浏览器提供支持,并且只有 50% 的浏览器支持这种类型的伪类,所以,如果我是你,我会这样做:
希望它有效;)
EDIT: You have to supply support for the most browsers, and only 50% of the browsers supports that type of pseudoclasses, so, if i was you, i would do this:
hope it works ;)
apply:
到你的CSS,它应该可以工作。
apply:
to your css and it should work.