浏览器CSS兼容

<!--[if lt IE 7]><body class="ie ie6"><![endif]--><!--[if IE 7]><body class="ie ie7"><![endif]--><!--[if IE 8]><body class="ie ie8"><![endif]--><!--[if !IE]><!--><body class="standard"><!--<![endif]--> 


可以使用如下形式(以IE6为例),为特定版本的IE使用特定的样式达到IE不同版本间的样式兼容 
    <!--[if lte IE 6]> 
<link href="http://www.cnblogs.com/Content/DropdownMenuIE6.css" rel="Stylesheet" type="text/css" /> 
<![endif]--> 
这里的<!--[if lte IE 6]>和<![endif]-->之间除了可以使用link标签引用样式外,还可以用style标签声明特定的样式。 

#example { color: #333; } /* FF及其他浏览器*/ 
* html #example { color: #666; } /* IE6 */ 
*+html #example { color: #999; } /* IE7 */ 
注意: 
*+html 对IE7的HACK 必须保证HTML顶部有如下声明: 
以下为引用的内容: 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
"http://www.w3.org/TR/html4/loose.dtd"> 

可以使用以下HTML: 
<meta http-equiv="x-ua-compatible" content="ie=7" /> 
让IE8使用兼容IE7的样式模式。 

1, !important 
随着IE7对!important的支持, !important 方法现在只针对IE6的HACK.(注意写法.记得该声明位置需要提前.) 
PLAIN TEXT 
CSS: 
#wrapper 

width: 100px!important; /* IE7+FF */ 
width: 80px; /* IE6 */ 

2, IE6/IE77对FireFox 
*+html 与 *html 是IE特有的标签, firefox 暂不支持.而*+html 又为 IE7特有标签. 
PLAIN TEXT 
CSS: 
#wrapper 

#wrapper { width: 120px; } /* FireFox */ 
*html #wrapper { width: 80px;} /* ie6 fixed */ 
*+html #wrapper { width: 60px;} /* ie7 fixed, 注意顺序 */ 
}

posted on 2011-09-25 20:45  cw_volcano  阅读(244)  评论(0编辑  收藏  举报