日期:2014-05-17  浏览次数:20655 次

css样式兼容不同浏览器问题

css样式兼容不同浏览器问题

所有浏览器 通用
height: 100px;

IE6
专用

_height: 100px;

IE6
专用

*height: 100px;

IE7
专用

*+height: 100px;

IE7
FF 共用

height: 100px !important;
一、CSS 兼容

以下两种方法几乎能解决现今所有兼容.

1, !important (
不是很推荐,用下面的一种感觉最安全
)

随着IE7!important的支持, !important 方法现在只针对IE6的兼容.(注意写法.记得该声明位置需要提前
.)

代码
:
<style>
#wrapper {
width: 100px!important; /* IE7+FF */
width: 80px; /* IE6 */
}
</style>

2, IE6/IE77
FireFox <from 针对firefox ie6 ie7css样式
>

*+html
*html IE特有的标签, firefox 暂不支持.*+html 又为 IE7特有标签
.

代码
:
<style>
#wrapper { width: 120px; } /* FireFox */
*html #wrapper { width: 80px;} /* ie6 fixed */
*+html #wrapper { width: 60px;} /* ie7 fixed,
注意顺序
*/
</style>

注意
:
*+html
IE7的兼容 必须保证HTML顶部有如下声明: