CSS hack

参考地址:http://www.cnblogs.com/top5/archive/2009/11/24/1609784.html


IE8正式版出来有一段日子了,但是针对ie8正式版的CSS hack却很少,其实这是值得庆幸的,因为ie8修复了很多IE6和IE7的一些BUG,更加接近W3C标准。

针对IE8正式版的CSS hack目前可以找到的分为2种:

第一种:”\9″:

基本的写法:

1. .test { color/*\**/: blue\9 }

这个IE6、IE7、IE8都能识别;但是IE8不能识别“*”和“_”的css hack;所以我们可以这样写hack:(转载

1. .header {width:300px;} /* 所有浏览器*/
2. .header {width/*\**/:330px\9;} /* 所有浏览器IE浏览器 */
3. .header {*width:310px;} /* IE7和IE6能识别,IE8和FF不能识别*/
4. .header {_width:290px;} /* IE6能识别,IE7、IE8和FF不能识别*/

第二种:就是使用IE的条件注释

具体可以查看这里:http://www.css88.com/archives/705

其他一些css hack的测试:

1. .color1{ color:#F00; color/*\**/:#00F /*\**/}/*IE6,IE7,IE8,FF,OP,SA识别*/
2. .color2{ color:#F00; color /*\**/:#00F /*\9**/}/*IE7,IE8,FF,OP,SA识别*/
3. .color3{ color:#F00; color/*\**/:#00F \9}/*IE6,IE7,IE8识别*/
4. .color4{ color:#F00; color /*\**/:#00F\9}/*IE7,IE8识别*//*“color”和“/*\**/”之间有个空格*/

其中:OP表示Opera,SA表示Safari

参考阅读:

http://ladysign-apps.com/blog/archives/529

http://webdevelop.nitamihai.com/ie8-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=utf-8" />
<title>区别IE6、IE7、IE8、FireFox的CSS hack - www.newcss.cn</title>
<style type="text/css">
<!--
#test,#note{
margin:0 auto;
text-align:center;
}
#test {
width:200px;
height:30px;
border: 1px solid #000000;
color:#fff;
line-height:30px;
}
.color{
background-color: #CC00FF; /*所有浏览器都会显示为紫色*/
background-color: #FF0000\9; /*IE6、IE7、IE8会显示红色*/
*background-color: #0066FF; /*IE6、IE7会变为蓝色*/  
_background-color: #009933; /*IE6会变为绿色*/
}
-->
</style>
</head>

<body>
<div id="test" class="color">测试方块 hi.baidu.com/dpxdqx </div>
<div id="note">
<strong style="color:#009933">IE6</strong>
<strong style="color:#0066FF">IE7</strong>
<strong style="color:#FF0000">IE8</strong>
<strong style="color:#CC00FF">FireFox</strong>
</div>
</body>
</html>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值