如何解决打印时还有一个空白页
我正在尝试打印页面,当我尝试打印页面时,它在末尾显示了另一个空白页面。我曾尝试将height: 99% !important; page-break-after: avoid;
添加到CSS中,但是没有用。我尝试了stackoverflow中的大多数解决方案。
这是我的代码
<html>
<head>
<style type="text/css" media="print">
@media print {
html,body {
margin: 0;
padding: 0;
width: 100%;
height: 99% !important;
page-break-after: avoid;
page-break-before: avoid;
}
table:nth-of-type(2) {
margin-bottom: 0;
page-break-inside: avoid;
}
@page {
page-break-inside: avoid;
size: A4 landscape;
margin: 10;
}
}
</style>
<style type="text/css">
page {
background: white;
display: block;
margin: 0 auto;
margin-bottom: 0.5cm;
box-shadow: 0 0 0.5cm rgba(0,0.5);
}
page[size="A4"] {
width: 21cm;
height: 29.7cm;
}
page[size="A4"][layout="landscape"] {
width: 29.7cm;
height: 21cm;
}
.table-wtotbr {
width: 100%;
}
.table-wtbr {
width: 100%;
}
.table-wtotbr th,td {
border-bottom: 1px solid black;
}
.table-wtbr th,td {
border: 1px solid black;
}
.container-table {
width: 100%;
height: 100%;
font-size:16px;
}
</style>
</head>
<body>
<page size="A4" layout="landscape">
<div class="container-table"></div>
</page>
</body>
</html>
任何人都可以帮助我解决这个问题吗?并且有任何方法可以添加打印功能。 预先谢谢你。
解决方法
我将css更改为这样
@media print {
html,body {
margin: 0 !important;
padding: 0 !important;
width: 100%;
height: 100vh !important;
}
}
这里重要的是height: 100vh !important;
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。