我想声明一个不同于 ie6 和 ie7 的风格,
但我的CSS条件被IE7识别为IE6。我用的是XP和explorer 7。
这是我使用的代码:
<!--[if !IE]>
#mainDiv{text-align:-moz-center;}
#skyBanner {top:0px;left:0px; position:fixed;visibility:hidden;}
<![endif]-->
<!--[if lt IE 7]>
body > #skyBanner { position: fixed;}
#skyBanner {position:absolute;visibility:hidden;
left: expression( ( 0 + ( ignoreMe2 = document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft ) ) + 'px' );
top: expression( ( 0 + ( ignoreMe = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop ) ) + 'px' );
}
<![endif]-->
<!--[if IE 7]>
#skyBanner {position:fixed;visibility:hidden;
}
<![endif]-->
我的错误是什么?
您不能在 CSS 中使用条件注释。仅在 HTML 中。因此,您必须将不同浏览器的声明放入不同的文件中,并对多个文件进行条件注释<link>
给他们。
更多类似的事情
<html>
<head>
<!--[if !IE]>
<link rel="stylesheet" type="text/css" href="style_non_ie.css">
<![endif]-->
...
</head>
</html>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)