网页的兼容性是个很严重的问题,为了网页能够兼容IE678 火狐,使用了各种方法,今天无意中看了一下 hao123 的源码。
<!--[if IE 6]>
<style type="text/css">
#aside .rc_lb{left:-1px;bottom:-2px;}#aside .rc_rb{right:-1px;bottom:-2px;}#content .rc_rt{right:-3px;top:-2px;}#content .rc_rb{right:-3px;bottom:-2px;}.tool_box a{zoom:1;padding-top:1px;}
</style>
<![endif]-->
<!--[if gte IE 7]>
<style type="text/css">
#header .tool_box a{zoom:1;line-height:19px;}#header .tool_box a.set_home{background-position:left -96px;}
</style>
<![endif]-->
我以前知道有 <!--[if IE 6]> 这句可以针对ie6做设置,没想到 ie7 也可以。
经过,我的测试 win2003 server x86 IE8 火狐3.68
发现 hao123 上写的有误。
正确代码:
<html>
<head><title>IE6 IE7 css 测试</title></head>
<body>
<!--[if IE 6]>
<style>
div {background-color:#f00;}
</style>
<![endif]-->
<!--[if gte IE 7]>
<style>
div {background-color:#0f0;}
</style>
<![endif]-->
<!--[if gte IE 8]>
<style>
div {background-color:#00f;}
</style>
<![endif]-->
<div>IE6 IE7 css 测试</div>
</body>
</html>
错误 IE7 8 效果一样
<html>
<head><title>IE6 IE7 css 测试</title></head>
<body>
<style>
div {background-color:#0f0;}
</style>
<!--[if IE 6]>
<style>
div {background-color:#f00;}
</style>
<![endif]-->
<!--[if gte IE 7]>
<style>
div {background-color:#00f;}
</style>
<![endif]-->
<div>IE6 IE7 css 测试</div>
</body>
</html>
- 上一篇:超简单的JS收缩菜单
- 下一篇:简体繁体切换问题