3

所以我一直在尝试让一些 CSS 下拉菜单在 IE 7 和 8 中工作

它们在其他浏览器上运行良好。

网址是:http ://hanling.focusww.com

我有一个 css 块,并且包含一些我想从 IE 7 和 8 中隐藏的行

我在最后用“*”标记了这些行。

#menu a:visited {
  color:#f9f6e0;
  display:block;
  font-weight:700;
  padding-bottom:10px; //kill this in ie *
  padding-left:12px;
  padding-right:12px;
  padding-top:10px;  //kill this in ie *
}

有人可以向我指出一篇解释如何做到这一点的文章吗?

4

3 回答 3

7

您可以通过以下简单方式做到这一点IE conditional comments

HTML

<!--[if IE 7]> <html class="ie7"> <![endif]-->
<!--[if IE 8]> <html class="ie8"> <![endif]-->

CSS

#menu a:visited {
  color:#f9f6e0;
  display:block;
  font-weight:700;
  padding-bottom:10px; //kill this in ie *
  padding-left:12px;
  padding-right:12px;
  padding-top:10px;  //kill this in ie *
}

.ie7 #menu a:visited,
.ie8 #menu a:visited, {
  padding-bottom: 0; //kill this in ie *
  padding-top: 0;  //kill this in ie *
}

..或者也可以使用CSS-Hacks更多:http ://www.webdevout.net/css-hacks#in_css

#menu a:visited {
 color:#f9f6e0;
 display:block;
 font-weight:700;
 padding-bottom:10px; 
 padding-bottom:0\9; //kill this in ie *
 padding-left:12px;
 padding-right:12px;
 padding-top:10px;  
 padding-top:0\9; //kill this in ie *
}
于 2012-12-14T17:53:31.133 回答
1

您可以使用 IE 条件注释,不能在 IE 中隐藏特定样式,甚至 @yckart 链接也很酷,但最好使用特定样式表

<!--[if IE 7]>
    Only Shows Up In IE7
    <link href="#" rel="stylesheet" type="text/css" />
<![endif]-->

<!--[if IE 8]>
    Only Shows Up In IE8
    <link href="#" rel="stylesheet" type="text/css" />
<![endif]-->
于 2012-12-14T17:50:19.520 回答
1

我会这样做:

#menu a:visited {
 color:#f9f6e0;
 display:block;
 font-weight:700;
 padding-bottom:10px; 
 padding-bottom:0\9; //IE 8 and below
 padding-left:12px;
 padding-right:12px;
 padding-top:10px;  
 padding-top:0\9; //IE 8 and below

}

如果这些是您唯一需要的特定于 IE 的样式,那么这可能比使用条件样式表更容易。

于 2012-12-14T18:01:05.787 回答