2

我有以下 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]--> 
4

1 回答 1

0

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.

<style type="text/css" rel="stylesheet" href="stylesheet_media.css" screen="media">
<style type="text/css" rel="stylesheet" href="stylesheet_print.css" screen="print">
于 2011-08-06T09:13:26.150 回答