CSS 仅适用于 IE 8
我需要仅针对 IE 8 设置某些项目的样式。如果我这样做:
<!--[if IE 8]><link rel="stylesheet" href="mystyleIE8.css" type="text/css" media="screen, projection"/><![endif]-->
然后我这样做:
<!--[if IE 7]><link rel="stylesheet" href="myStyleIE7.css" type="text/css" media="screen, projection"/><![endif]-->
会发生什么?我发现这个链接到之前的SO问题这意味着
I need to style some items for only IE 8. If I do this:
<!--[if IE 8]><link rel="stylesheet" href="mystyleIE8.css" type="text/css" media="screen, projection"/><![endif]-->
and then I do:
<!--[if IE 7]><link rel="stylesheet" href="myStyleIE7.css" type="text/css" media="screen, projection"/><![endif]-->
What will happen? I found this link to a previous SO question which implied that <!--[if IE 8]>
means "If IE 8 or lower". Does this mean that using <!--[if IE 8]>
will overwrite all <!--[if IE 7]>
css? Will my program know to use <!--[if IE 8]>
for only IE 8 and <!--[if IE 7]>
for IE 7?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
它并不意味着“如果 IE 8 或更低版本”。
意思是如果是IE8
如果小于IE 8
如果小于或等于IE 8
It does not mean "If IE 8 or lower".
Means if it is IE8
If it is less than IE 8
If it is less than or equal to IE 8
如果按照示例执行操作,IE8 将获取 mystyleIE8.css,IE7 将获取 mystyleIE7.css。
这些称为条件注释。您可以针对其他场景使用其他语法。在此示例中:
“stuff”仅适用于 Internet Explorer 7 及更低版本的所有版本。
有关详细信息,请参阅 http://www.quirksmode.org/css/condcom.html , 例如。
If you do as in your example, IE8 will get mystyleIE8.css and IE7 will get mystyleIE7.css.
These are called conditional comments. You could use other syntaxes for other scenarios. In this example:
the "stuff" would only apply to all versions of Internet Explorer 7 and lower.
For more, see http://www.quirksmode.org/css/condcom.html, for example.
凯蒂克是正确的。如果你看看里面的评论:
表示“如果浏览器是IE版本8”,仅包括IE8。
表示“如果浏览器是IE版本7”,仅包括IE7。
有语法允许小于。但你所展示的并不是这样。对比
表示“如果浏览器低于或等于 IE 版本 8”,其中包括 IE8、IE7、IE6 和 IE5.5。
表示“如果浏览器低于或等于 IE 版本 7”,其中包括 IE7、IE6、IE5.5。
KatieK is correct. If you look inside the comments:
Means "If the browser is IE version 8", which includes only IE8.
Means "If the browser is IE version 7", which includes only IE7.
There's syntax that DOES allow less than. But what you showed isn't it. Contrast with
Means "If the browser is less than or equal to IE version 8", which includes IE8, IE7, IE6, and IE5.5.
Means "If the browser is less than or equal to IE version 7", which includes IE7, IE6, and IE5.5.
您可以尝试以下CSS Hacks。有趣的东西。
You can try the following CSS Hacks. Interesting stuff.