Internet Explorer 8不会修改打印样式表中的HTML5标记

Jam*_*ite 8 printing html5 header footer nav

我之前正在处理打印样式表,并遇到了IE8的问题.我正在使用HTML5和几个布局标签,包括标题,导航和页脚.

出于某种原因,在我的打印样式表中,display:none; 在IE8中忽略了这些标签上的声明(我只能假设后续的较低版本).我首先想到IE9中的Developer Tools可能会导致错误表示,但我在VirtualBox中安装了Windows XP,这也显示了问题.

我的猜测是因为IE9以下的任何东西都看不到HTML5标签.打印样式表隐藏了Firefox和Chrome中的布局标签.

反正有没有绕过这个?

编辑:

这就是我现在所拥有的:

<link rel="stylesheet" href="<?php echo get_template_directory_uri(); ?>/style.css" type="text/css" media="screen" />
<link rel="stylesheet" href="<?php echo get_template_directory_uri(); ?>/css/print.css" type="text/css" media="print" />
Run Code Online (Sandbox Code Playgroud)

忽略PHP语句,它们特定于我的CMS,即WordPress.

然后我只是在print.css中隐藏布局标签:

nav,footer { 
display:none;
}
Run Code Online (Sandbox Code Playgroud)

这适用于IE9,Firefox,Chrome但不低于IE9.它似乎忽略了HTML5标签.

Jef*_* To 14

我建议你试试html5shiv.主要的shiv document.createElement()像你一样,但它已被疯狂地优化/缩小.更重要的是,它包括printshiv(IE Print Protector),它可以让你为HTML5元素设置打印样式.