0

在我的网页中,我使用了 2 个样式表:

<link rel="stylesheet" href="css/screen-layout.css" media="screen" type="text/css" />
<link rel="stylesheet" href="css/print-layout.css" media="print" type="text/css" />

里面print-layout.css有:

.ui-dialog * {display: none !important;}

当我在 IE7 上查看我的网页时,它应该忽略那个media="print",但它没有,它应用了display: none,导致所有元素都被隐藏。在 IE7 的调试栏插件中,我可以看到 IE7 应用了该print-layout.css文件。这怎么可能?还是我错过了在 IE7 上使用打印的任何要求?

谢谢 :)

4

1 回答 1

4

该语法甚至适用于 IE7,但如果您需要将该浏览器排除在应用您的打印样式之外,只需以这种方式重写您的最后一个包含:

<style type="text/css" rel="stylesheet">
   @import url('css/print-layout.css') print;
</style>

因为 IE7 没有在@import规则上实现媒体类型。

否则只需将第二个包含在条件注释中,就像这样

<!--[if (gte IE 8)]><!-->
   <link rel="stylesheet"... media="print" /> 
<!--<![endif]-->

所以你包括所有浏览器的打印样式,除了IE < 8.


附带说明:IE7 的使用是全球性的< 1%
请参阅http://gs.statcounter.com/#browser_version-ww-monthly-201211-201304

于 2013-05-02T08:53:33.740 回答