Html Page Break not working

前端 未结 2 682
萌比男神i
萌比男神i 2021-01-26 03:12

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 thi

相关标签:
2条回答
  • 2021-01-26 03:47

    Your css needs to be

    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

    "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)

    try putting a div after the hr like so

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

    and changing your CSS to

    div.applicant-break {page-break-after:always;}
    
    0 讨论(0)
  • 2021-01-26 03:52

    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 m.t! :)

    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.

    0 讨论(0)
提交回复
热议问题