1

作为这个问题的后续,我如何防止 Internet Explorer 加载多个样式表,(因为我希望 Firefox 和 Chrome 加载一个,而 IE 加载另一个?)是放置引用的顺序吗?或相同的文件名但在不同的文件夹中,我需要做一种if else声明,还是什么?

例如,IE 是否会加载两者:

<!--[if IE]>
    <link href="/Content/SiteIE.css" rel="stylesheet" type="text/css">
<![endif]-->
<link href="/Content/Site.css" rel="stylesheet" type="text/css">
4

2 回答 2

4

完整的语法是:

<!--[if IE]>
According to the conditional comment this is IE<br />
<![endif]-->
<!--[if IE 6]>
According to the conditional comment this is IE 6<br />
<![endif]-->
<!--[if IE 7]>
According to the conditional comment this is IE 7<br />
<![endif]-->
<!--[if IE 8]>
According to the conditional comment this is IE 8<br />
<![endif]-->
<!--[if IE 9]>
According to the conditional comment this is IE 9<br />
<![endif]-->
<!--[if gte IE 8]>
According to the conditional comment this is IE 8 or higher<br />
<![endif]-->
<!--[if lt IE 9]>
According to the conditional comment this is IE lower than 9<br />
<![endif]-->
<!--[if lte IE 7]>
According to the conditional comment this is IE lower or equal to 7<br />
<![endif]-->
<!--[if gt IE 6]>
According to the conditional comment this is IE greater than 6<br />
<![endif]-->
<!--[if !IE]> -->
According to the conditional comment this is not IE<br />
<!-- <![endif]-->

来源:http ://www.quirksmode.org/css/condcom.html

于 2012-08-18T21:11:35.427 回答
1

是的,它会同时加载两者。但我有时会做的是使 IE 特定规则具有更高的特异性,以便它比其他浏览器的其他规则具有更高的顺序

于 2012-08-18T21:14:06.363 回答