CSS 你如何在 IE8 中设置禁用 textarea 的样式?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5485642/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 00:05:46  来源:igfitidea点击:

How do you style disabled textarea in IE8?

cssinternet-explorer-8

提问by Marwelln

What rule do you need to enable styling of disabled elements in IE8? I have the code below now. It that works fine under IE7, but not on IE8. IE8 just give me plaint wihte background. Why?

在 IE8 中启用禁用元素的样式需要什么规则?我现在有下面的代码。它在 IE7 下工作正常,但在 IE8 上不工作。IE8 只是给我哀叹背景。为什么?

input[disabled], input:disabled, textarea[disabled], textarea[disabled="disabled"], textarea:disabled {
    background:#EBEBE4;
}

回答by clairesuzy

the :pseudo class in the selector is tripping up IE8!

选择器中的 :pseudo 类正在绊倒 IE8!

you have to ungroup these selectors if you absolutely have to use those CSS3 pseudo classes;

如果您绝对必须使用那些 CSS3伪类,则必须取消这些选择器的组合;

If there's a selector in the ruleset that IE8 doesn't understand it's ignoring the whole thing - this is common in IE8 with CSS3 pseudo classes

如果规则集中有一个 IE8 不理解的选择器,它会忽略整个事情 - 这在 IE8 中很常见,带有 CSS3 伪类

e.g. If you separate them out and remove the pseudo :disabledparts of the selector completely - you'll see the first example below works for all, whereas the second one still works except for IE7

例如,如果您将它们分开并完全删除:disabled选择器的伪部分 - 您将看到下面的第一个示例适用于所有人,而第二个示例仍然适用于 IE7

input[disabled], select[disabled], textarea[disabled] {background-color: #0f0;} /* lime green - works in IE7+ and modern browsers */

input[disabled="disabled"], select[disabled="disabled"], textarea[disabled="disabled"] {background-color:#ff0;} /* yellow -  IE8+ and modern browsers */

the color (as opposed to background-color) issue pointed at in another answer is not the cause of your issue, but it wouldn't help if you were also trying to change the color ;)

另一个答案中指出的颜色(与背景颜色相反)问题不是您问题的原因,但如果您也尝试更改颜色,则无济于事;)

回答by bluefoot

Another option is to add a disabledclass and style it:

另一种选择是添加一个disabled类并为其设置样式:

input.disabled, textarea.disabled{ 
    background:#EBEBE4; 
}