区别 ff, ie7.0, ie6.0不同浏览器,CSS hack写法

1.
*+html 与 *html 是IE特有的标签, firefox 暂不支持,而*+html 又为 IE7特有标签。因此便可以很方便的得到一个针对于
FireFox、IE6、IE7三种不通浏览器的hack实例代码如下:

<html> <head> <mce:style><!-- #wrapper { width: 120px;height:100px; background:#ff0; } /* FireFox */ *html #wrapper { width: 80px;} /* ie6 fixed */ *+html #wrapper { width: 60px;} /* ie7 fixed, 注意顺序 */ --></mce:style><style mce_bogus="1">#wrapper { width: 120px;height:100px; background:#ff0; } /* FireFox */ *html #wrapper { width: 80px;} /* ie6 fixed */ *+html #wrapper { width: 60px;} /* ie7 fixed, 注意顺序 */ </style> </head> <body> <div id="wrapper"></div> </body> </html>

2.
IE6能识别*,但不能识别 !important,IE7能识别*,也能识别!important;FF不能识别*,但能识别!important;因此也可以写出一个针对于FireFox、IE7、IE6三种不通浏览器的hack实例代码如下:

<html> <head> <mce:style><!-- #wrapper { width: 120px;*width: 60px !important;*width: 80px;height:100px; background:#ff0;} /*注意 firefox的写在前面,IE7的写在中间,IE6的写在最后面*/ --></mce:style><style mce_bogus="1"> #wrapper { width: 120px;*width: 60px !important;*width: 80px;height:100px; background:#ff0;} /*注意 firefox的写在前面,IE7的写在中间,IE6的写在最后面*/</style> </head> <body> <div id="wrapper"></div> </body> </html>

3.
还有可以利用的是ie6.0支持下划线(即"_"),
因此也能写出一个针对于FireFox、IE7、IE6三种不通浏览器的hack实例代码如下:
<html> <head> <mce:style><!-- #wrapper { width: 120px;*width: 60px;_width: 80px;height:100px; background:#ff0;} /*注意 firefox的写在前面,IE7的写在中间,IE6的写在最后面*/ --></mce:style><style mce_bogus="1">#wrapper { width: 120px;*width: 60px;_width: 80px;height:100px; background:#ff0;} /*注意 firefox的写在前面,IE7的写在中间,IE6的写在最后面*/</style> </head> <body> <div id="wrapper"></div> </body> </html>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值