IE8浏览器的CSS hack怎么写(css,hack,ie,web开发)

时间:2024-04-29 15:06:59 作者 : 石家庄SEO 分类 : web开发
  • TAG :

    IE8%E6%B5%8F%E8%A7%88%E5%99%A8%E7%9A%84CSS+hack%E6%80%8E%E4%B9%88%E5%86%99

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怎么写的详细内容,希望对您有所帮助,信息来源于网络。
上一篇:CSS hack怎么区别不同浏览器下一篇:

7 人围观 / 0 条评论 ↓快速评论↓

(必须)

(必须,保密)

阿狸1 阿狸2 阿狸3 阿狸4 阿狸5 阿狸6 阿狸7 阿狸8 阿狸9 阿狸10 阿狸11 阿狸12 阿狸13 阿狸14 阿狸15 阿狸16 阿狸17 阿狸18