【问题标题】:Conditional comments for CSS in IE9IE9 中 CSS 的条件注释
【发布时间】:2014-02-03 09:33:47
【问题描述】:
我想为 IE9 添加一个特定的样式表,它用不同的边距值覆盖 img.icon css 类。所以我在头部添加了以下内容。但是当页面加载时,它会在浏览器中显示为文本。
<!--[if IE 9]>
img.icon {
float: right;
margin: 4px -31px;
}
<![endif]-->
【问题讨论】:
标签:
javascript
css
internet-explorer-9
【解决方案1】:
您缺少<style> 标签
<!--[if IE 9]>
<style>
img.icon {
float: right;
margin: 4px -31px;
}
</style>
<![endif]-->
【解决方案2】:
<!--[if IE9]>
<style>
img.icon {
float: right;
margin: 4px -31px;
}
</style>
<![endif]-->
它认为
【解决方案3】:
您忘记了样式标签。
<!--[if IE 9]>
<style>
img.icon {
float: right;
margin: 4px -31px;
}
</style>
<![endif]-->
此外,您可能会发现在条件 cmets 中加载外部样式表更容易:
<!--[if IE 9]>
<link rel="stylesheet" href="css/ie9.css">
<![endif]-->