CSS样式兼容 火狐Google IE9,8,7,6 CSS定义顺序
作者:佚名 时间:2014-08-13
body {
background-color:Black;
background-color:red\9\0;
background-color:blue\0;
*background-color:navy;
_background-color:green;
}
注意点: IE9 支持 \9\0, 中间不要有空格,写成 background-color:red \9\0;不会识别。必须 background-color:red\9\0;
IE8 支持 \0,同样中间不要有空格。
IE6,IE7 都支持 * ,但是IE6特别还支持 下划线_, 如果要特别针对IE6,可以加下划线, 比如支持IE7 写成 *background-color:navy;
仅支持IE6的写法 _background-color:green;
定义顺序: 火狐Google>IE9>IE8>IE7>IE6;
上面是针对一个 元素的一个css属性。 如果 要整体兼容 一段CSS代码, 就要这么写
#Menu{
width:1005px; height:30px;background:red; margin:0px auto;
}
*html #Menu {
width:1005px; height:30px;background:navy; margin:0px auto;
}
*+html #Menu {
width:1005px; height:30px;background:gray; margin:0px auto;
}
*:first-child+html #Menu {
width:1005px; height:30px;background:gray; margin:0px auto;
}
IE7 的 *+html #Menu 和*:first-child+html #Menu 2种写法,效果一样,不知道有啥差别,希望网友能给出意见。
注意点: IE6,7都支持*, IE7 特别支持+号。
当然,如果不一样的css设置 非常多, 可以针对不同浏览器写css样式, 在浏览器的头部 根据不同浏览器来加载css。
首先默认加载通用样式
<link rel="stylesheet" type="text/css" href="http://www.linksj.com" />
<!--[if IE 6]>
<link rel="stylesheet" type="text/css" href="http://www.linksj.com" />
<![endif]-->
<!--[if IE 7]>
<link rel="stylesheet" type="text/css" href="http://www.linksj.com" />
<![endif]-->
还有其他浏览器,格式如下
<!--[if !IE]><!--> 除IE外都可识别 <!--<![endif]-->
<!--[if IE]> 所有的IE可识别 <![endif]-->
<!--[if IE 6]> 仅IE6 <![endif]-->
<!--[if lt IE 6]> IE6以及IE6以下 <![endif]-->
<!--[if gte IE 6]> IE6以及IE6以上 <![endif]-->
<!--[if IE 7]> 仅IE7 <![endif]-->
<!--[if lt IE 7]> IE7以及IE7以下<![endif]-->
<!--[if gte IE 7]> IE7以及IE7以上 <![endif]-->
<!--[if IE 8]> 仅IE8 <![endif]-->
<!--[if IE 9]> 仅IE9 <![endif]-->
国内生产的一些所谓的浏览器,都是用的国外的内核,其中大部分是IE内核。写代码的时候,主要考虑IE各个版本和火狐Google。
由于目前大部分用户还集中在XP时代,所以IE6还占据一部分市场,还停留在IE6时代。
虽然国外已经流行Windows 7 IE9,火狐 最新浏览器,国内真是落后几个节拍。
IE内核浏览器:
世界之窗(The World)
傲游浏览器(Maxthon)
腾讯TT(Tencent Traveler)
爱帆浏览器(Avant Browser)
360安全浏览器(360SE)
搜狗浏览器(兼容模式)(Sougou Explorer)
瑞影浏览器(Rayying)
也有的事开源基金的内核:360极速浏览器