以前的一篇博文 ie6、ie7、ie8、Firefox兼容性问题 写的比较混乱,可能有的童鞋看不明白,所以今天有空我就重新整理了一份 CSS HACK 的写法。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<title>css hack</title>
<style type="text/css">
.demo{width:100px;height:100px;border:5px solid orange;}
.demo1{
background:black; /* for all */
}
.demo2{
background:green\9; /* for ie */
}
.demo3{
background:yellow\0; /* for ie8 */
}
.demo4{
*background:blue; /* for ie7,ie6 */
}
.demo5{
_background:red; /* for ie6 */
}
</style>
</head>
<body>
<div class="demo demo1"></div><br/>
<div class="demo demo2"></div><br/>
<div class="demo demo3"></div><br/>
<div class="demo demo4"></div><br/>
<div class="demo demo5"></div>
</body>
</html>
测试的浏览器:IE6-9,Firefox,Google,Safari
PS:博客搬家了,以后不再 CSDN 更新了,见谅。最新博客地址:http://www.cnblogs.com/yjzhu/