浏览器hack详细介绍

发布于:
分类: Script Tagged

IE系列浏览器的hack大略如下:

_nowamagic:1px;-----------ie6
*nowamagic:1px;-----------ie7
nowamagic:1px;----------ie89
nowamagic:1px9;--------ie9
:root nowamagic:1px;    ----ie9(实际情况可能ie9还是有问题,再用这种方式)

 

1.‘9’:

.test { color/***/: blue9 }
.header {width:300px;} /* 所有浏览器*/
.header {width/***/:330px\9;} /* 所有浏览器IE浏览器 */
.header {*width:310px;} /* IE7和IE6能识别,IE8和FF不能识别*/
.header {_width:290px;} /* IE6能识别,IE7、IE8和FF不能识别*/

2.利用条件注释语句:
<!–[if IE]> 此内容只有IE可见 <![endif]–>

lt 表示less than 当前条件版本以下的版本,不包含当前版本。
gte 表示greeter than or equal 当前版本以上版本,并包含当前版本。
lte 表示less than or equal 当前版本以下版本,并包含当前版本。

3.其它hack 技术:

.color1{ color:#F00; color/***/:#00F /***/}/*IE6,IE7,IE8,FF,OP,SA识别*/
.color2{ color:#F00; color /***/:#00F /*9**/}/*IE7,IE8,FF,OP,SA识别*/
.color3{ color:#F00; color/***/:#00F 9}/*IE6,IE7,IE8识别*/
.color4{ color:#F00; color /***/:#00F9}/*IE7,IE8识别*//*“color”和“/***/”之间有个空格*/

 

标准模式 IE6 TE7 IE8 IE9 FF Chrome 使用示例
× × × × × #tmp{-color:red;}
_ × × × × × #tmp{_color:red;}
+ × × × × #tmp{+color:red;}
= × × × × #tmp{=color:red;}
~ × × × × #tmp{~color:red;}
! × × × × #tmp{!color:red;}
@ × × × × #tmp{@color:red;}
# × × × × #tmp{#color:red;}
$ × × × × #tmp{$color:red;}
% × × × × #tmp{%color:red;}
^ × × × × #tmp{^color:red;}
& × × × × #tmp{&color:red;}
* × × × × #tmp{*color:red;}
× × × × #tmp{‘color:red;}
\9 × × #tmp{color:red\9;}
\0 × × × × #tmp{color:red\0;}
html>/**/body × × html>/**/body #tmp{-color:red;}
!important × #tmp{color:red !important;}
:root × × × :root #tmp{-color:red;}

 

hack IE6(S) IE6(Q) IE7(S) IE7(Q) IE8(S) IE8(Q) 示例
* Yes Yes Yes Yes No Yes *color
+ Yes Yes Yes Yes No Yes +color
Yes Yes No No No No -color
_ Yes Yes No Yes No Yes _color
# Yes Yes Yes Yes No Yes #color
\0 No No No No Yes No color\0
\9 Yes Yes Yes Yes Yes Yes color\9
!important No No Yes No Yes No color:blue !important;
color:green;

标准模式中:

1,减号(-)是IE6专有hack

2,反斜杠零(\0)是IE8专有hack

留下评论

您的电子邮箱地址不会被公开。 必填项已用 * 标注