像其他许多人一样,我真的讨厌为IE7开发,并且像往常一样使用下面的方法:
<!--[if IE 7]>
<link rel="stylesheet" type="text/css" href="../res/styleie7.css">
<![endif]-->这针对的是浏览器版本的IE7,而不是IE7的文档标准。
我需要为使用更新版本的IE(IE8,9,10)但将其浏览器设置为使用IE7标准的用户提供一种方法。有没有一种方法可以检测到这一点,而不仅仅是检测浏览器版本?
发布于 2013-10-23 16:10:08
我通常使用将class属性附加到HTML的方法:
<!--[if IE 7 ]><html class="no-js ie7" lang="en"><![endif]-->
<!--[if IE 8 ]><html class="no-js ie8" lang="en"><![endif]-->
<!--[if IE 9 ]><html class="no-js ie9" lang="en"><![endif]-->
<!--[if (gte IE 9)|(gt IEMobile 7)|!(IEMobile)|!(IE)]><!--><html class="no-js" lang="en"> <!--<![endif]-->这样,您就可以在CSS中添加IE前缀,例如:
.ie7 .selector {
properties
}例如,当我在IE7模式下运行IE10时,这种方法是有效的
发布于 2013-10-23 16:25:31
<!--[if lt IE 7]> <html lang="en" class="no-js ie lt-ie10 lt-ie9 lt-ie8 lt-ie7 ie6"> <![endif]-->
<!--[if IE 7]> <html lang="en" class="no-js ie lt-ie10 lt-ie9 lt-ie8 ie7"> <![endif]-->
<!--[if IE 8]> <html lang="en" class="no-js ie lt-ie10 lt-ie9 ie8"> <![endif]-->
<!--[if IE 9]> <html lang="en" class="no-js ie lt-ie10 ie9"> <![endif]-->
<!--[if IE 10]> <html lang="en" class="no-js ie ie10"> <![endif]-->
<!--[if !IE]><!--><html lang="en" class="no-js"><!--<![endif]-->把这段代码放在你的
现在你的ie7的css是
.ie7 .yourclass-or-id{
}现在你的ie8的css是
.ie8 .yourclass-or-id{
}现在你的ie9的css是
.ie9 .yourclass-or-id{
}现在你的ie10的css是
.ie10 .yourclass-or-id{
}发布于 2013-10-23 16:26:08
https://stackoverflow.com/questions/19536132
复制相似问题