目标IE9或IE8,但不能同时使用CSS [英] Target IE9 or IE8 but not both using CSS
问题描述
我知道这不应该做,但我只想要一个快速修复现在,这将给我时间找到一个适当的修复这个。
I know it shouldn't be done, but I just want a quick fix for now and that will give me time to find a proper fix for this.
如何使用CSS单独定位IE8,因为我已尝试附加 \9
,例如:
How can I target IE8 alone using CSS because I've tried appending \9
such as:
margin:100px\9;
但是,它也会影响IE9,我不想这样,因为在IE9整个网站看起来很好。
However, it also affects IE9 and I don't want that because on IE9 the whole site looks fine.
推荐答案
从 HTML5 Boilerplate 和最初来自 Paul Irish :
将< html> 标记更改为:
<!--[if lt IE 7 ]> <html lang="en" class="ie6"> <![endif]-->
<!--[if IE 7 ]> <html lang="en" class="ie7"> <![endif]-->
<!--[if IE 8 ]> <html lang="en" class="ie8"> <![endif]-->
<!--[if IE 9 ]> <html lang="en" class="ie9"> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--> <html lang="en"> <!--<![endif]-->
然后IE8会在html标签中添加一个.ie8类。相同的所有其他版本的IE。你可以这样做:
Then IE8 will add a .ie8 class to the html tag. Same for all the other versions of IE. You can then do:
.ie8 {
margin:100px;
}
修改: js 类,请将 lang =属性更新为您的语言。谢谢,眼睑。
Removed the no-js class, and please update the lang="" attribute to your language. Thanks, eyelidlessness.
这篇关于目标IE9或IE8,但不能同时使用CSS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!