IE只有样式表,如何阻止IE加载其他样式表(IE only style sheets, how to

2019-10-17 04:22发布

作为跟进这个问题 ,我如何阻止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">

Answer 1:

完整的语法是:

<!--[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



Answer 2:

是的,它会同时加载。 但我有时做的是,使IE浏览器的具体规则有较高的特异性,使其接管意味着其他浏览器其他的高阶



文章来源: IE only style sheets, how to prevent IE from loading other style sheets