【问题标题】:Why is IE using styles from media=print CSS?为什么 IE 使用来自 media=print CSS 的样式?
【发布时间】:2011-09-26 23:12:26
【问题描述】:

我有以下 HTML,其中向 CSS 类添加了 DHTML 行为。当代码按以下方式编写时,Internet Explorer(兼容模式下的版本 8)也会读取 @media 打印,而不是仅使用顶部样式。

<!--[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]--> 

【问题讨论】:

  • 它是应用所有属性还是只应用边界半径?尽管在媒体查询中,但可能始终执行该行为

标签: css dhtml html-components


【解决方案1】:

IE8 使用打印 CSS 而不是媒体 CSS,因为打印 CSS 是内联的,而不是来自外部文件。这段代码会有所帮助。

<style type="text/css" rel="stylesheet" href="stylesheet_media.css" screen="media">
<style type="text/css" rel="stylesheet" href="stylesheet_print.css" screen="print">

【讨论】:

    猜你喜欢
    • 2013-01-15
    • 1970-01-01
    • 1970-01-01
    • 2015-04-07
    • 2013-04-26
    • 1970-01-01
    • 1970-01-01
    • 2012-10-12
    • 2018-08-25
    相关资源
    最近更新 更多