IE8正式版 CSS hack

发布时间:2009.04.15 12:19
分类:Html/Javascript/Css
标签:,

目前网络上大部分关于ie8的hack都是测试版的,最有名的可能要数那张linxz.cn的hack图片了,这张图片估计被国内的网友转载了几十万次,但目前这张图里的方法对IE8正式版是无效的。

刚刚在网上看到一篇关于ie8正式版css hack的文章,就想收藏过来了。
以下的IE8均指IE8正式版,版本号:8.0.6001.18702

"\9" 例:"margin:0px auto\9;"。这里的"\9"所有的IE都识别,但Firefox不识别。
"*" IE6、IE7可以识别。IE8、FireFox不能。
"_" IE6可以识别"_",IE7、IE8、FireFox不能。

如此,就可以完全区分开IE6、IE7、IE8、FireFox了。
例子:

<!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</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;		/*所有浏览器都会显示为紫色*/
	background-color: #FF0000\9;	/*IE6、IE7、IE8会显示红色*/
	*background-color: #0066FF;		/*IE6、IE7会变为蓝色*/			
	_background-color: #009933;		/*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>
</body>
</html>
上一篇: 下一篇:

你的留言:

声明:
1、本站启用了审核机制,你的留言可能稍后才会显示,请不要重复提交,谢谢。
2、留言时的头像是Gravatar提供的服务。想设置的看这里