
Code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>区别IE6、IE7、IE8、FireFox的CSS hack - www.bjedu.com</title>
<style type="text/css">
<!--
#test,#note{
margin:0 auto;
text-align:center;
}
#test {
width:200px;
height:30px;
border: 1px solid #000000;
color:#fff;
line-height:30px;
}
.color{
background-color: #CC00FF; /*所有浏览器都会显示为紫色 FF*/
background-color: #FF0000\9; /*IE6、IE7、IE8会显示红色 IE8*/
*background-color: #0066FF; /*IE6、IE7会变为蓝色 IE7*/
_background-color: #009933; /*IE6会变为绿色 IE6*/
}
.ad_div_07 {
width:822px;
float:left;
overflow:hidden;
background-color:#00CCFF;
}
.ad_div_07 ul { margin:0px; padding:0px;}
.ad_div_07 ul li {
width:180px;
height:53px;
border:1px solid #000000;
float:left;
list-style:none;
margin-bottom:6px;
margin-top:6px;
margin-left:20px; /*所有浏览器都会显示为紫色 FF*/
margin-left:20px\9; /*IE6、IE7、IE8会显示红色 IE8*/
*margin-left:20px; /*IE6、IE7会变为蓝色 IE7*/
_margin-left:12px; /*IE6会变为绿色 IE6*/
}
-->
</style>
</head>
<body>
<div id="test" class="color">测试方块</div>
<div id="note">
<strong style="color:#009933">IE6</strong>
<strong style="color:#0066FF">IE7</strong>
<strong style="color:#FF0000">IE8</strong>
<strong style="color:#CC00FF">FireFox</strong>
</div>
<div class="ad_div_07">
<ul>
<li> </li>
<li> </li>
<li> </li>
<li> </li>
<li> </li>
<li> </li>
</ul>
</div>
</body>
</html>
主要部分:
margin-left:20px; /*所有浏览器都会显示为紫色 FF*/
margin-left:20px\9; /*IE6、IE7、IE8会显示红色 IE8*/
*margin-left:20px; /*IE6、IE7会变为蓝色 IE7*/
_margin-left:12px; /*IE6会变为绿色 IE6*/