`
cw_volcano
  • 浏览: 16940 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
文章分类
社区版块
存档分类
最新评论

浏览器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="../../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, 注意顺序 */
}
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics