针对IE6,IE7,firefox的CSS hack写法

针对IE6,IE7,firefox的CSS hack写法:

区别 IE6 FF
background: orange ; * background: blue ;
区别 IE6 IE7
background: green !important ;background: blue ;
区别 IE7 FF
background: orange ; * background: green ;
区别 FF IE7 IE6
background: orange ; * background: green !important ;*background: blue ;
注:
IE都能识别*;标准浏览器(如FF)不能识别*;
IE6能识别*,但不能识别 !important,
IE7能识别*,也能识别!important;
FF不能识别*,但能识别!important;
IE6IE7FF
*×
!important×

另外再补充一个,下划线"_ ",
IE6支持下划线,IE7和firefox均不支持下划线。

于是大家还可以这样来区分IE6 IE7 firefox
: background:orange ;* background:green ;_ background:blue ;

注:不管是什么方法,书写的顺序都是firefox的写在前面,IE7的写在中间,IE6的写在最后面。


IE6跟Firefox之间的差异问题可以用 !important 来解决(这种方法尽量少用),但是IE7似乎还是不认识 !important ,而且它跟IE6之间也存在一些差异。浏览器的不一致性总是让人很头疼!

下面分别给出IE6/IE7/Firefox的hack代码:

#example { color: #333; } /* Firefox */* html #example { color: #666; } /* IE6 */*+html #example { color: #999; } /* IE7 */

那么在Firefox下字体颜色显示为#333,IE6下字体颜色显示为#666,IE7下字体颜色显示为#999,他们之间互不干扰。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值