以前我写CSS代码大部分都是用!important来hack。
在ie6和firefox环境中测试可以正常显示,并成功的应用了hack技术。
但是发布了ie7后,它对!important可以正确解释,页面没有能够按要求显示!

我找到一个针对IE7不错的hack方式:使用“*+html”!
现在用IE7浏览一下,应该没有问题了。

示例如下:
#example { color: #333; } /* Mozilla FireFox*/
* html #example { color: #666; } /* IE6 */
*+html #example { color: #999; } /* IE7 */

那么在firefox下字体颜色显示为#333,
IE6下字体颜色显示为#666,
IE7下字体颜色显示为#999,并且它们互不干扰!

区别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都能识别*;符合web标准的浏览器(如firefox)不能识别*

总结
IE6能识别*,但不能识别 !important,
IE7能识别*,也能识别!important;
FF不能识别*,但能识别!important;

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

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

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

相关日志:
Tags:

http://www.dngz.net/blog/index.php/focuses-on-the-ie6-ie7-how-to-use-css-hack-firefox.html

我想发表对此文的看法 ...

登录 , 注册

有一条评论

  1. No.1 qqq :
    02月 22nd, 2008 at 8:04 pm

    不错 。。学习了 。。。