Enforce Print Page Breaks with CSS

拈花ヽ惹草 提交于 2019-11-29 11:10:30

short answer. You can't it's not consistetly supported across all browsers. there is slightly better support for page-break-before than page-break-after though...

see page-break-before compatibility and page-break-after compatibility

you could also try embedding a Ctrl-L in the page at those points thought I'm pretty sure a lot of printer drivers are gonna ignore that.

ashurexm

By setting the min-height in the WOPrint CSS class I'm able to fake an approximate page break for a standard height page:

.WOPrint
    {
        max-width: 100%;
        padding-bottom: 3em;
        min-height: 9in;
    }

All you need is

.WOPageBreak
{
    page-break-before: always;
}

However, you'll also want to add "overflow:visible" to the body tag because without it Firefox will only print the first page.

You may also get more consistent results if you set margin:0 on the body when printing, like so:

@media print{body{margin:0}}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!