我需要以A4尺寸打印html页面,另外我还想与CSS,html一起打印内容正文打印,并忽略菜单列表,页眉,页脚和页面右侧菜单列表。
首先,我介绍了简单的div和class noprint并将其添加到@media print中,但它似乎不起作用。noprint类在@media打印之外工作,因此我知道它是正确的。
另外,我的要求是使用标准Ctrl + P键盘选项直接从浏览器进行打印
<style type="text/css">
.standardStyle {
display:block;
width:200px;
height:150px;
padding:10px;
background-color:green;
margin:5px;
}
@media print{
.noprint{ color:red;}
}
</style>
</head>
<body>
<div class="noprint standardStyle">
this is test line....
</div>
<div class="print standardStyle">
this is test line....
</div>
<div class="print standardStyle">
this is test line....
</div>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句