如何在打印结束时避免额外的空白页? [英] how to avoid extra blank page at end while printing?

查看:281
本文介绍了如何在打印结束时避免额外的空白页?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是CSS属性,

I'm using a CSS property,

如果我使用 page-break-after:always; =>在

如果我使用 page-break-before:always; =>它后面打印一个额外的空白页。 如何避免此问题?

If I use page-break-before: always; => It prints an extra blank page after. How to avoid this?

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<style type="text/css">
.print{
    page-break-after: always;

}
</style>
<script type="text/javascript">
window.print();
</script>
</head>
<body>
<div class="print">fd</div>
<div class="print">fdfd</div>
</body>
</html>


推荐答案

您可以添加

.print:last-child {
     page-break-after: auto;
}

因此最后的 print 元素不会得到额外的分页符。

so the last print element will not get the extra page break.

请注意:IE8不支持last-child选择器,如果你定位浏览器的wretch 。

Do note that the :last-child selector is not supported in IE8, if you're targetting that wretch of a browser.

这篇关于如何在打印结束时避免额外的空白页?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆