Html {page-break-after: always} 打印时不工作

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16989843/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 09:13:02  来源:igfitidea点击:

{page-break-after: always} not working when printing

htmlcsspage-break

提问by ItsPronounced

EDIT: I just noticed this works in IE9, but not IE10 and Chrome.

编辑:我刚刚注意到这在 IE9 中有效,但在 IE10 和 Chrome 中无效。

We receive HTML formatted PO reports from one of our suppliers electronically. We usually print these and before it would put 1 PO per page, but now it is not adding the page breaks. I checked the html and I can't see why it wouldn't work all of a sudden. This is the (poorly formatted) html:

我们以电子方式从我们的供应商之一收到 HTML 格式的采购订单报告。我们通常打印这些,之前每页放置 1 个 PO,但现在它不添加分页符。我检查了 html,我不明白为什么它突然不起作用。这是(格式错误的)html:

<HEAD>
<STYLE TYPE='text/css'><!--
BR.breakhere {page-break-after: always}
.tb1{font:10pt Arial;}
.tb2{border-left:1px solid #000000; border-right:1px solid #000000;border-top: 1px  solid #000000;border-bottom: 1px solid #000000;}
.tb3{font:10pt Arial;border-left:1px solid #000000; border-right:1px solid #000000;border-top: 1px  solid #000000;border-bottom: 1px solid #000000;}
.tb4{font-size:8pt;}
--></STYLE>
</HEAD>

The page break is suppose to occur here:

分页符应该发生在这里:

<BR class=breakhere>

It occurs immediately after a TABLE element, the TABLE has an HR after the last TR (ugh).

它紧跟在 TABLE 元素之后,TABLE 在最后一个 TR (ugh) 之后有一个 HR。

<BR><HR style = "width:100%;height:10px;color:#000000"></TABLE><BR class=breakhere>

I want to contact them and mention this but I'm not sure if it is the code or something on our end? I've tried every browser, multiple printers and workstations, but can't get it to break pages.

我想联系他们并提及这一点,但我不确定这是代码还是我们这边的东西?我已经尝试了所有浏览器、多台打印机和工作站,但无法让它断页。

Thanks!

谢谢!

采纳答案by JamesIngold

I've been dealing with this too. It appears that using the page-break-after property in a break line is a no-no in IE10. According to Internet Explorer's current documentation supporting CSS 2.1 Section 13.3.1, the page-break-after property does not support line break or header elements. See the remarks in this link: http://msdn.microsoft.com/en-us/library/ie/ms530842. I had to switch my code to use a div with the break after class but that doesn't seem to work in IE9 which is awesome.

我也一直在处理这个。在断行中使用 page-break-after 属性似乎是 IE10 中的禁忌。根据支持 CSS 2.1 第 13.3.1 节的 Internet Explorer 当前文档,page-break-after 属性不支持换行符或标题元素。请参阅此链接中的备注:http: //msdn.microsoft.com/en-us/library/ie/ms530842。我不得不将我的代码切换为在课后休息时使用 div 但这似乎在 IE9 中不起作用,这太棒了。

回答by Mumin Ka

page-break is not enough for internet explorer by own. If u try this, you can see the result. I have same problem but I solved by this way.

分页对 Internet Explorer 来说是不够的。如果你试试这个,你可以看到结果。我有同样的问题,但我通过这种方式解决了。

<div style="page-break-after: always;"></div>
<div>&nbsp;
</div>