您可以使用这样的事情:
<!--[if lt IE 7]> <html class="ie6"> <![endif]-->
<!--[if IE 7]> <html class="ie7"> <![endif]-->
<!--[if IE 8]> <html class="ie8"> <![endif]-->
<!--[if gt IE 8]><!--> <html> <!--<![endif]-->
然后通过针对您的选择:
.ie8 .your-selector
如所述here。
如果你想有一个开关,你也可以在一个类的html标签,例如,
<!--[if gt IE 8]><!--> <html class ="i-am-so-happy-it-is-no-ancient-ie"><!--<![endif]-->
,并使用它像这样:
.i-am-so-happy-it-is-no-ancient-ie .your-selector{...}
.ie6 .your-selector {...}
编辑 我忘了IE 9 .. NOTE:事实上保罗爱尔兰建议使用这种形式(由我略作调整,以使非即开关可以使用单.IE的.class - 虽然你必须要知道,IE 6不支持多类,但你的想法):
<!--[if lt IE 7 ]> <html class="ie6 ie"> <![endif]-->
<!--[if IE 7 ]> <html class="ie7 ie"> <![endif]-->
<!--[if IE 8 ]> <html class="ie8 ie"> <![endif]-->
<!--[if IE 9 ]> <html class="ie9 ie"> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--> <html class="no-ie"> <!--<![endif]-->
有关说明原因,请参阅上面的link。
,条件注释仅用于IE浏览器。一般来说,我所做的是首先加载常见案例,然后使用条件注释加载IE版本特定的CSS。 –
这些被称为_conditional comments_,并广泛记录在网络上。 – CBroe
另外,IE 10不支持条件注释。 –