温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

IE8浏览器的CSS hack怎么写

发布时间:2022-03-09 17:01:24 来源:亿速云 阅读:107 作者:iii 栏目:web开发

这篇文章主要介绍“IE8浏览器的CSS hack怎么写”的相关知识,小编通过实际案例向大家展示操作过程,操作方法简单快捷,实用性强,希望这篇“IE8浏览器的CSS hack怎么写”文章能帮助大家解决问题。

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怎么写”的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识,可以关注亿速云行业资讯频道,小编每天都会为大家更新不同的知识点。

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI