打印时如何避免在末尾出现额外的空白页? [英] how to avoid extra blank page at end while printing?
本文介绍了打印时如何避免在末尾出现额外的空白页?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用 CSS 属性,
I'm using a CSS property,
如果我使用 page-break-after: always;
=> 它会在之前打印一个额外的空白页
If I use page-break-after: always;
=> It prints an extra blank page before
如果我使用 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.
请注意 :last-child 选择器在 IE8 中不受支持,如果您的目标是浏览器的那个可怜虫.
Do note that the :last-child selector is not supported in IE8, if you're targetting that wretch of a browser.
这篇关于打印时如何避免在末尾出现额外的空白页?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文