IE7 on XP渲染media =“print”样式表 [英] IE7 on XP render the media="print" stylesheets
问题描述
在我的网页中,我使用了2种样式表:
< link rel =stylesheethref = css / screen-layout.cssmedia =screentype =text / css/>
< link rel =stylesheethref =css / print-layout.cssmedia =printtype =text / css/>
在 print-layout.css
:
.ui-dialog * {display:none!important;}
当我在IE7上查看我的网页时,应该忽略 media =print
但它没有,它应用 display:none
,导致所有的元素被隐藏。在IE7的debugbar插件中,我可以看到IE7应用了 print-layout.css
文件。这怎么可能?
这种语法也适用于IE7,但如果你需要排除浏览器应用你的打印样式,只需用这种方式重写你最后一个包含:
< style type =text / css =stylesheet>
@import url('css / print-layout.css')print;
< / style>由于IE7尚未在 @import $>上实现媒体类型,因此
$ b
否则只是将第二个包含在条件注释中, p> <! - [if(gte IE 8)]><! -
< link rel =stylesheet... media =print/>
<! - <![endif] - >
所以你包括所有浏览器的打印样式,除了 IE< 8
。
注意:IE7的使用是全球性的 < 1%
:
请参阅 http://gs.statcounter.com/#browser_version-ww-monthly-201211-201304
In my web page, I'm using 2 stylesheets :
<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" />
inside print-layout.css
there is :
.ui-dialog * {display: none !important;}
When I viewed my webpage on IE7, it's supposed to ignore the media="print"
one, but it didn't, it applied the display: none
, causing all the elements to be hidden. And in the debugbar plugin for IE7, I can see that IE7 applied the print-layout.css
file. How is that possible? or am I missing any requirements for using print on IE7?
Thanks :)
That syntax works even on IE7 but if you need to exclude that browser from applying your print style, just rewrite your last inclusion in this way:
<style type="text/css" rel="stylesheet">
@import url('css/print-layout.css') print;
</style>
since IE7 hasn't implemented the media type on @import
rule.
Otherwise just wrap the second inclusion in a conditional comment, like so
<!--[if (gte IE 8)]><!-->
<link rel="stylesheet"... media="print" />
<!--<![endif]-->
so you include the print style for all browser except IE < 8
.
As a side note: IE7 usage is globally < 1%
:
see http://gs.statcounter.com/#browser_version-ww-monthly-201211-201304
这篇关于IE7 on XP渲染media =“print”样式表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!