为什么 IE 使用 media=print CSS 中的样式?
我有以下 HTML,其中向 CSS 类添加了 DHTML 行为。当代码按以下方式编写时,Internet Explorer(兼容模式下的版本8)也会读取@media打印,而不是仅使用top样式。
<!--[if IE]>
<style>
.roundCorners {
border: 1px solid #b4b4b4;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
border-radius: 5px;
background: #fff;
behavior: url(/css/border-radius.htc);
}
@media print {
.roundCorners {
border: 5px solid #b4b4b4;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
border-radius: 5px;
background: #fff;
behavior: url(/css/border-radius_remove.htc);
}
}
</style>
<![endif]-->
I have the following HTML where there is a DHTML behavior added to the CSS class. When the code is written in the following way, Internet Explorer (version 8 in compatibility mode) reads the @media print as well instead of using the top style only.
<!--[if IE]>
<style>
.roundCorners {
border: 1px solid #b4b4b4;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
border-radius: 5px;
background: #fff;
behavior: url(/css/border-radius.htc);
}
@media print {
.roundCorners {
border: 5px solid #b4b4b4;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
border-radius: 5px;
background: #fff;
behavior: url(/css/border-radius_remove.htc);
}
}
</style>
<![endif]-->
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
IE8 使用打印 CSS 而不是媒体 CSS,因为打印 CSS 是内联的,而不是来自外部文件。这段代码会有所帮助。
IE8 is using the print CSS instead of the media one, because the print CSS is inline, and not coming from an external file. This code will help.