为什么非ie浏览器使用!important来读取IE条件?

bet*_*208 -3 html css internet-explorer cross-browser

当使用带有!important的IE Con​​ditionals(例如下面的代码)时,无论浏览器是什么背景都默认为背景颜色!重要甚至在IE条件内.

怎么可以重写这个,以便浏览器接受IE9和其他浏览器中低于IE9的背景颜色和图像(高度/宽度:100%,不重复)?

注意:我打算在Wordpress网站中使用它,默认情况下主题会自动设置颜色或图像,因此我必须使用!important来覆盖默认主题样式.

body {
<!--[if lt IE 9]>
background-color:#c1beb2 !important;
background:#c1beb2 !important;
<![endif]-->
<!--[if gte IE 9]>
background-image: url("http://example.com/wp-content/example.png") !important;
background-position:left bottom;
background-size: 100% 100%;
background-repeat: no-repeat;
<![endif]-->
<![if !IE]>
background-image: url("http://example.com/wp-content/example.png") !important;
background-position:left bottom;
background-size: 100% 100%;
background-repeat: no-repeat;
<![endif]>
}
Run Code Online (Sandbox Code Playgroud)

chi*_*len 6

条件注释旨在用于HTML,而不是CSS.

也就是说,在HTML中链接到这样的IE特定样式表:

<!--[if lte IE 9]> 
<link rel="stylesheet" href="/ie.css" type="text/css" media="no title" charset="utf-8" />
<![endif]-->
Run Code Online (Sandbox Code Playgroud)

这是正确的方法.如果您不想创建一个完整的其他IE特定样式表,您可以依赖CSS IE Hacks.