CSS浏览器兼容----IE的定制CSS样式

#条件声明(在另一篇文章中已有详细讲解说明了),也是解决IE兼容性最常用的方法

<!--[if IE 8]>
<style type="text/css">
	/* css for IE 8 */
</style>
<![endif]-->

<!--[if lt IE 8]>
	<link href="ie7.css" rel="stylesheet" type="text/css" />
<![endif]-->

#对于不同版本的IE相应的CSS规则,也是一种可选择的方式。

IE8及或下版本:添加9(9)属性后

IE7或以下版本:添加属性前添加*

IE6:属性前添加_

.box {
	
	background: gray; /* standard */

	background: pink9; /* IE 8 and below */

	*background: green; /* IE 7 and below */

	_background: blue; /* IE 6 */

}

#条件声明里面,添加<html>的Class:

这种方法是Paul Irish发明的,使用相应的IE class作为父类例如:

  .ie6 .box

<!--[if lt IE 7 ]> <html class="ie6"> <![endif]-->
<!--[if IE 7 ]> <html class="ie7"> <![endif]-->
<!--[if IE 8 ]> <html class="ie8"> <![endif]-->
<!--[if IE 9 ]> <html class="ie9"> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--> <html> <!--<![endif]-->
<style type="text/css">
body {
	background: #efefef;
	font: 1em/1.5em Arial, Helvetica, sans-serif;
	color: #666;
	 80%;
	margin: 20px auto;
}
a {
	color: #F60;
}
.box {
	color: #fff;
	padding: 5px 20px;
	background: gray; 
}
.ie8 .box {
	background: pink;
}
.ie7 .box {
	background: green;
}
.ie6 .box {
	background: blue;
}
</style>

  

#下面是显示结果不同IE下的一个例子:

 VIEW DEMOIE Specific

 

原文地址:https://www.cnblogs.com/IanI/p/4024342.html