简体   繁体   English

HTML分页符不起作用

[英]Html Page Break not working

Trying to set a page break in the page I'm working on but in the print preview I'm still seeing things on the page that aren't supposed to be there. 尝试在我正在处理的页面上设置分页符,但是在打印预览中,我仍然看到页面上不应该存在的内容。 Can't figure out why this isn't working. 无法弄清楚为什么这不起作用。

In my css style: 在我的CSS风格中:

.applicant-break hr {page-break-after:always;}

In my ASP.NET code...partial view of code the start tags are there: 在我的ASP.NET代码...代码的部分视图中,开始标记在其中:

<b>Resume</b>
<br />
<asp:Literal runat="server" ID="litResume"></asp:Literal>
<br />
<br />             
<hr class="applicant-break" />
</ItemTemplate>
</asp:Repeater>  
</asp:Panel>

Any help would be appreciated. 任何帮助,将不胜感激。

Your css needs to be 您的CSS需要

hr.applicant-break {page-break-after:always;}

EDIT: 编辑:

Doing some reading on the W3Schools website , it seems this css property is meant for table elements W3Schools网站上进行一些阅读,似乎此css属性用于表元素

"Set the page-breaking behavior to always break after a table element" “将分页行为设置为始终在表元素之后中断”

EDIT: 编辑:

Doing some more reading, it seems browsers do support more than the table element, however some browsers have trouble with it on HR and BR tags ( Reading here ) 做更多的阅读,似乎浏览器不支持table元素,但是有些浏览器在HR和BR标签上有麻烦( 在这里阅读

try putting a div after the hr like so 尝试像这样在小时后放置div

<hr />
<div class="applicant-break"></div>

and changing your CSS to 并将您的CSS更改为

div.applicant-break {page-break-after:always;}

So apparently I'm silly, I was trying to trust the print preview of Chrome instead of just actually printing it myself, upon printing it I see that the page break does in fact work, thanks for your assistance mt! 因此,很显然我很傻,我试图信任Chrome的打印预览,而不是自己亲自打印,打印后我发现分页符实际上可以正常工作,感谢您的帮助mt! :) :)

So fair warning to anyone else reading this, while it is useful it doesn't always give you an accurate look at your print job all the time. 因此,对其他阅读本书的人也是如此警告,尽管它很有用,但它并不能始终使您始终准确地了解自己的打印作业。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM