最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Print html to multiple page - Stack Overflow

programmeradmin8浏览0评论

Assuming we have multiple html paragraph

<p>Paragraph 1</p>
<p>Paragraph 2</p>

Is there a way to print both to different page to the printer ?

Paragraph 1 would be printed on the first page and Paragraph 2 would be printed on the second page.

Thank You

Assuming we have multiple html paragraph

<p>Paragraph 1</p>
<p>Paragraph 2</p>

Is there a way to print both to different page to the printer ?

Paragraph 1 would be printed on the first page and Paragraph 2 would be printed on the second page.

Thank You

Share Improve this question asked Jan 13, 2015 at 18:30 ConfusedUserConfusedUser 3911 gold badge4 silver badges14 bronze badges 2
  • stick enough <br> tags between them, and they'll end up on different pages. Or, you could just style for print ! – adeneo Commented Jan 13, 2015 at 18:33
  • 1 Good way to choke on <br>'s ... :) – sodawillow Commented Jan 13, 2015 at 18:36
Add a ment  | 

1 Answer 1

Reset to default 35

You can do this using CSS page-break-after property:

@media print {
    p { page-break-after: always; }
}

It will print each p element on new page.

window.print()
@media print {
    @page { margin: 0; }
    p { page-break-after: always; }
}
<p>Paragraph 1</p>
<p>Paragraph 2</p>

发布评论

评论列表(0)

  1. 暂无评论