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:
如何更改IE中禁用的SELECT元素的字体颜色?无论我尝试什么,它都是灰色的。我可以将背景从灰色更改为白色,但禁用的SELECT中的文本保持不变。在IE中,完美的火狐浏览器对字体颜色没有影响(在这里是IE8)。您可以在这里看到这两个浏览器的最新情况:
http://www.flickr.com/photos/64416865@N00/4732813702/
http://www.flickr.com/photos/64416865@N00/4732813702
I use jQuery to disable the select element:
我使用jQuery禁用select元素:
$(selectObject).attr('disabled', 'disabled');
and here is the CSS class that I use for disabled selects:
这是CSS类,我用于禁用的选择:
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?)
我发现很奇怪,我可以很容易地更改禁用选择的默认背景颜色,而不是默认字体颜色。对此有什么建议或想法吗?(或者在IE中使用CSS是完全不可能的?)
3 个解决方案
#1
3
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 )
在目前的情况下,这可能是不可能的。接下来的浏览器可能会支持:禁用的伪类(参见http://www.w3.org/Style/CSS/Test/CSS3/Selectors/current/html/full/flat/css3-modsel-24.html)
#2
2
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:
编辑:您必须为大多数浏览器提供支持,只有50%的浏览器支持这种类型的伪类,因此,如果我是您,我将这样做:
$(selectObject)
.attr('disabled', 'disabled')
.css({
"color":"black",
"background-color":"white",
"border-style":"solid"
});
hope it works ;)
希望它工作。)
#3
-1
apply:
应用:
background-image: url('');
to your css and it should work.
对于你的css,它应该起作用。
#1
3
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 )
在目前的情况下,这可能是不可能的。接下来的浏览器可能会支持:禁用的伪类(参见http://www.w3.org/Style/CSS/Test/CSS3/Selectors/current/html/full/flat/css3-modsel-24.html)
#2
2
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:
编辑:您必须为大多数浏览器提供支持,只有50%的浏览器支持这种类型的伪类,因此,如果我是您,我将这样做:
$(selectObject)
.attr('disabled', 'disabled')
.css({
"color":"black",
"background-color":"white",
"border-style":"solid"
});
hope it works ;)
希望它工作。)
#3
-1
apply:
应用:
background-image: url('');
to your css and it should work.
对于你的css,它应该起作用。