为什么@media打印不起作用,我甚至在这个网站上搜索谷歌,也没有任何帮助,所以我发布了这个问题。 我在谷歌Chrome打印预览(ctrl p)上测试它,但我也打印到页面,并保持空白。CSS @media print根本不工作
我试着制作一个单独的CSS文件,并在页面中嵌入CSS样式。
这里是我的代码
页眉
<link rel="stylesheet" type="text/css" href="css/reset.css" />
<link rel="stylesheet" type="text/css" href="css/style.css" />
<link rel="stylesheet" type="text/css" href="css/print.css" media="print" />
HTML
<div id="bruikleenovereenkomst">
<div id="blo_header">
</div>
<div id="blo_side_top"></div>
<div id="blo_side_bottom"></div>
</div>
CSS样式正常
div#bruikleenovereenkomst {
width:595px;
height:842px;
background-color:#fff;
position:relative;
}
div#blo_header {
width:100%;
height:125px;
background-color:#FBE983;
z-index:9
}
div#blo_side_top {
width:57px;
height:420px;
background-color:#B6CAE5;
position:absolute;
right:0;
top:0;
z-index:99;
}
div#blo_side_bottom {
width:57px;
height:420px;
background-image:url(../images/leaflet.png);
background-repeat:no-repeat;
position:absolute;
right:0;
bottom:0;
z-index:99;
}
CSS打印样式(print.css)提示:div #bruikleenovereenkom st只是一个黑色的测试块。
@media print{
body {
margin:0;
}
h1#logo {
display:none;
}
ul#menu {
display:none;
}
div#bruikleenovereenkomst {
width:100%;
height:500px;
background-color:#000;
}
div#blo_header {
display:none;
}
div#blo_side_top {
display:none;
}
div#blo_side_bottom {
display:none;
}
}
我所得到的只是一个空白页。
也许背景不打印?尝试将一些真实的内容放在那里,看看它是否有效。 – adamse
但我需要一个彩色打印页面....有没有办法,我可以给div打印颜色? – Julez
阅读stackoverflow上的其他答案似乎这是在浏览器中,你不能用css覆盖的设置。 – adamse