区别 ff, ie7.0, ie6.0浏览器

1.*+html *html IE特有的标签, firefox 暂不支持,而*+html 又为 IE7特有标签。因此便可以很方便的得到一个针对于

FireFox
IE6IE7三种不通浏览器的hack实例代码如下:<o:p></o:p>

  1. <html>
  2. <head>
  3. <style>
  4. #wrapper { width: 120px;height:100px; background:#ff0; } /* FireFox */
  5. *html #wrapper { width: 80px;} /* ie6 fixed */
  6. *+html #wrapper { width: 60px;} /* ie7 fixed, 注意顺序 */
  7. style>
  8. head>
  9. <body>
  10. <div id="wrapper">div>
  11. body>
  12. html>

2. IE6 能识别 * ,但不能识别 !important,IE7 能识别 * ,也能识别 !important;FF 不能识别 * ,但能识别 !important; 因此也可以写出一个针对于

FireFox
IE7IE6 三种不通浏览器的 hack 实例代码如下:
  1. <html>
  2. <head>
  3. <style>
  4. #wrapper { width: 120px;*width: 60px !important;*width: 80px;height:100px;
  5. background:#ff0;}
  6. /*注意 firefox的写在前面,IE7的写在中间,IE6的写在最后面*/
  7. style>
  8. head>
  9. <body>
  10. <div id="wrapper">div>
  11. body>
  12. html>


3. 还有可以利用的是 ie6.0 支持下划线 ("_"), 因此也能写出一个针对于

FireFox
IE7IE6三种不通浏览器的hack实例代码如下:
  1. <html>
  2. <head>
  3. <style>
  4. #wrapper { width: 120px;*width: 60px;_width: 80px;height:100px; background:#ff0;}
  5. /*注意 firefox的写在前面,IE7的写在中间,IE6的写在最后面*/
  6. style>
  7. head>
  8. <body>
  9. <div id="wrapper">div>
  10. body>
  11. html>

当然hack远不止这些,只要了解属性在各浏览器中不同的解析原理或是能否识别,再加以组合就可以是一套用来解决浏览器兼容性的hack.
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值