0

我想知道如何根据检查浏览器是否小于 IE8 来删除所有 CSS 样式。

那么如果它检测到 IE7 则删除所有样式?我想知道这是否可以通过一些 jquery 实现?

这将修复大多数 IE7 问题:

<!--[if lt IE 7]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE7.js"></script>
<![endif]-->
4

3 回答 3

2

我不知道您为什么要删除浏览器版本的所有样式。我想你在使用 IE7 时遇到了一些 CSS 问题,通常一种修复它的好方法是使用 ie7.js,而不是删除所有 CSS:http ://code.google.com/p/ie7-js/ .

这是它可以做什么的演示

此外,此脚本有 IE8 和 IE9 版本。

于 2012-04-06T11:50:30.580 回答
1
<!--[if lt IE 8]>
    <body class='oldIE'>
<![endif]-->
<!--[if gte IE 8]>
    <body class='ok'>
<![endif]-->
<!--[if !IE]>
    <body class='ok'>
<![endif]-->

在这里,您需要为所有不使用 IE7 的样式添加前缀.ok

另一种方法是

<!--[if lt IE 8]>
    //include an old IE specific stylesheet or none at all
<![endif]-->
<!--[if gte IE 8]>
    //include your stylesheets
<![endif]-->
<!--[if !IE]>
    //include your stylesheets
<![endif]-->
于 2012-04-06T12:48:44.113 回答
0

最好的解决方案是删除特定的类名,而不是擦除元素的整个 CSS:

// Identity browser and browser version

if($.browser.msie && parseInt($.browser.version) == 7) {

   // Remove class name
   $('.class').removeClass('class');

   // Or unset each CSS selectively
   $('.class').css({
      'background-color': '',
      'font-weight': ''
   });

}
于 2012-04-06T11:50:41.143 回答