/*将CSS属性分别给IE7和IE8使用*/ .element { color: red; background: green; /* for non-IE7 */ _background: blue; /* for IE7 */ *background: yellow; /* for IE6 */ } /*给 IE6/7 中width、heght赋值*/ .element { width: 100px; /* for non-IE6/7 */ _width: 120px; /* for IE6 */ *width: 110px; /* for IE7 */ height: 200px; /* for non-IE6/7 */ _height: 220px; /* for IE6 */ *height: 210px; /* for IE7 */ } /* IE6/7 中字体会模糊,字体大小缩小即可*/ body { font-size: 12px; /* for non-IE6/7 */ _font-size: 14px; /* for IE6 */ } /*修复IE6的盒模型错误,自带边框宽度赋值方法*/ .element { width: 200px; height: 100px; padding: 10px; /* 为了方便此处没有写全,正确应该是padding: 10px 20px;*/ border: 1px solid black; _width: 218px; _height: 118px; _padding: 0 20px 10px; } /*IE6/7下,块级元素中a标签无法撑开div高度,需修改*/ .element { *display: inline-block; /* for IE6/7 */ *zoom: 1; /* for IE6/7 */ }
以上就是几种兼容 IE6/7/8 的 CSS 属性实例,希望对大家有所帮助。