1, IE條件註釋法,微軟官方推薦的hack方式。
只在IE下生效 <!--[if IE]> 這段文字只在IE瀏覽器上顯示 <![endif]--> 只在IE6下生效 <!--[if IE 6]> 這段文字只在IE6瀏覽器上顯示 <![endif]--> 只在IE6以上版本生效 <!--[if gt IE 6]> 這段文字只在IE6以上版本IE瀏覽器上顯示 <![endif]--> 只在IE7上不生效 <!--[if ! IE 7]> 這段文字在非IE7瀏覽器上顯示 <![endif]--> 非IE瀏覽器生效 <!--[if !IE]><!--> 這段文字只在非IE瀏覽器上顯示 <!--<![endif]-->
2, 選擇符前綴法,即在CSS選擇符前加一些只有特定瀏覽器才能識別的前綴。css
*html 前綴只對IE6生效
*+html 前綴只對IE7生效html
例如:
.test{ color:#FFF;}
*html .test{ color:#000;} /* only for ie6 */
*+html .test{ color:#CCC;} /* only for ie7 */express
3, 屬性前綴法,即在樣式屬性名前加一些只有特定瀏覽器才能識別的前綴。瀏覽器
「_」 只對IE6生效
「*」 只對IE6和IE7生效post
例如:
.test{ color:#FFF; *color:#CCC; _color:#000;}htm
4, 還有一種hack方法是在屬性值後加上一些只有特定瀏覽器才能識別的前綴。get
「\9″ IE6/IE7/IE8/IE9/IE10都生效
「\0″ IE8/IE9/IE10都生效
「\9\0″ 只對IE9/IE10生效
例如:
.test{ color:#FFF; color:#CCC\9; color:#3FC\0;}it
5.button重置css樣式兼容ie6,ie7io
button在IE六、IE7下的兼容性,須要充值css爲overflow:visibleclass
轉載
6.讓IE6支持max-width,min-width
.sector{max-width:500px; _width:expression((documentElement.clientWidth>500)?」500px」:」auto」);
min-width:300px; _width:expression((documentElement.clientWidth<300)?」300px」:」auto」);}