IE8浏览器的CSS hack怎么写
导读:本文共1678字符,通常情况下阅读需要6分钟。同时您也可以点击右侧朗读,来听本文内容。按键盘←(左) →(右) 方向键可以翻页。
摘要: CSS hack区分如下——注意顺序与浏览器CSS HACK位置:CSS hack:区分IE6,IE7 ,IE8,firefox区别不同浏览器,CSS hack写法:区别FF与IE6:background:orange;*background:blue; 解释:FF只能识别background:orange; IE6识别*... ...
目录
(为您整理了一些要点),点击可以直达。CSS hack区分如下——注意顺序与浏览器CSS HACK位置:
CSS hack:区分IE6,IE7 ,IE8,firefox
区别不同浏览器,CSS hack写法:
区别FF与IE6:
background:orange;*background:blue; 解释:FF只能识别background:orange; IE6识别*background:blue;
区别IE7与IE6:
background:green !important;background:blue;或者*background:green;_background:blue;
区别IE6与IE8:
background:orange; /*/background:blue;/**/
区别IE7与IE8:
background:orange; /*/background:blue;/**/
区别FF与IE7:
background:orange; *background:green !important;
区别FF,IE7,IE8,IE6:
background:orange;*background:green important;background:#111\9;_background:blue;
或者使用
区别FF,IE7,IE8,IE6:
background:orange;*background:green !important;background:#111\9;*background:blue;
CSS Hack实例例子:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>DIV+CSS各浏览器css hack测试,www..com测试</title>
<style type="text/css">
<!--
.STYLE1 { font-size:18px;color:#FF0000;*color:#00FF00 !important;color:#0000FF \9;*color:#FFFF00;}
.STYLE2,.STYLE3,.STYLE4,.STYLE5{ font-size:14px;}
.STYLE2 {color: #FFFF00}
.STYLE3 {color: #FF0000}
.STYLE4 {color: #00FF00}
.STYLE5 {color: #0000FF}
-->
</style>
</head>
<body>
<span class="STYLE1">我是测试颜色,不在不同浏览器下显示颜色不同哦!-<a href="http://www..com/">DIV+CSS</a></span><br />
<span class="STYLE2">我是颜色在IE6显示</span> <br />
<span class="STYLE4">我是颜色在ie7显示</span> <br />
<span class="STYLE5">我是颜色在ie8显示</span> <br />
<span class="STYLE3">我是颜色在火狐(firefox)显示</span>
</body>
</html>
以上代码你拷贝到一个新建的html文件在不同版本浏览器测试就会有不同效果。运用此例子即可解决我们在日常DIV+CSS开发时候的css hack问题。
同时我们如果不想那么的麻烦来做IE8的css hack,我们只需要在html的<head></head>之间加入<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />,最好加到CSS文件下发即可,在IE8 下和IE7下显示内容相同,这样我们只需区分IE6、IE7、火狐(firefox)的css hack即可。很多大型站点都采用在head加入此代码来减少css bug。
IE8浏览器的CSS hack怎么写的详细内容,希望对您有所帮助,信息来源于网络。