您的位置:首页 > Web前端 > CSS

css hack(CSS多浏览器兼容)

2010-04-24 08:48 316 查看
int i=0;
int j=1;

在web开发中,每个人都会遇到css对不同浏览器兼容的问题,虽然不是什么大问题,却着实让人费心,特别对于一些没有经验的开发者来说,是特别头疼的。经常会在网上看到有人抱怨浏览器版本太多,没办法,市场总是存在竞争的,有问题我们就想办法解决它吧。下边是本人总结的一些针对不同浏览器的css hack,希望能帮助需要的朋友。

background:blue;Firefox 背景变蓝色
background:red /9;IE8 背景变红色
*background:black;IE7 背景变黑色
_background:orange;IE6 背景变橘色
IE6以下
*html{}
IE 7 以下
*:first-child+html {} * html {}
只对IE 7
*:first-child+html {}
只对IE 7 和现代浏览器
html>body {}
只对IE 8(属性值后加/0)
.name {color:#ccc/0; }
只对现代浏览器(非IE 7)
html>/**/body {}
最新的Opera 9以下版本
html:first-child {}
Safari
html[xmlns*=”"] body:last-child {}
Firefox 3
.classname, x:-moz-any-link, x:default {}
#id, x:-moz-any-link, x:default {}

====================
所有浏览器下背景变灰(半透明)
body {filter:alpha(opacity=30);opacity:0.3;background-color:#ccc;}
====================
区别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;
区别FF 3
“{”前加上“, x:-moz-any-link, x:default”,只有FF 3能识别

注:
IE都能识别*;标准浏览器(如FF)不能识别*;
IE6能识别*,但不能识别 !important,
IE7能识别*,也能识别!important;
只有IE8能识别/0
FF不能识别*,但能识别!important;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: