利用条件注释语句

<!–[if IE]> 此内容只有IE可见 <![endif]–>

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

例子:

<!– 默认先调用css.css样式表 –>
<link rel=”stylesheet” type=”text/css” href=”css.css” />
<!–[if IE 7]><!– 如果IE浏览器版是7,调用ie7.css样式表 –>
<link rel=”stylesheet” type=”text/css” href=”ie7.css” />
<![endif]–>

IE6 css hack

*html selector{} /*selector表示css选择器*/
selector{_property:value;}
selector{_property/**/:/**/value;}
selector{-property:value;}

IE6 css hack常用习惯是使用下划线

IE7 css hack

*+html selector{} /*selector表示css选择器*/
*:first-child+html selector{}

IE8 css hack

selector{
	property: value; /*W3C MODEL*/
	property: value\0; /*IE 8+*/

}

IE6、IE7、IE8共有的css hack

selector{
	property: value\9; /*IE 9+*/

}

IE6、IE7共有的css hack

Selector { 
	*property: value;
	#property: value;
	+property: value;
}

IE8+ css hack

Selector { property: value\0;}

IE9+ css hack

Selector { property: value\9\0; }/*IE 9+*/