[英]how to style content of div on printing page using javascript/jquery?
I need to print content of a web page.我需要打印 web 页面的内容。 There is a print button below div div下面有一个打印按钮
<div class="printing-content">
</div>
<button class="btn -primary mr-1" onclick="window.print()"><span class="mdi mdi-printer"></span> Print</button>
my web page looks like:我的 web 页面如下所示:
here is my css这是我的 css
@media print {
body * {
visibility: hidden;
}
.printing-content * {
visibility: visible;
-webkit-print-color-adjust: exact;
}
.printing-content {
/* position: absolute; */
width: 100%;
left: 0;
top: 0;
}
}
i need to show div with full width on printed page.我需要在打印页面上显示全宽的 div。 Thanks in advance.提前致谢。
You could try using a media query and setting the size of the page to landscape?您可以尝试使用媒体查询并将页面大小设置为横向?
@media print{@page {size: landscape}}
For the div itself you can play around with the width and height of the div when it is printed also using a media query.对于 div 本身,您也可以使用媒体查询在打印 div 时使用它的宽度和高度。
@media print {
.printing-content {
width: 210mm;
height: 297mm;
}
}
Try play around with those width and height values.尝试使用这些宽度和高度值。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.