javascript - JS window print margins breaked table - Stack Overflow

I have a table that i want to print using JS window.print();.But when this table have too many lines o

I have a table that i want to print using JS window.print();. But when this table have too many lines oter pages dosen't preserve seted margins

My CSS:

@page { size:  auto; margin: 0px; }
html  { background-color: #FFFFFF; margin: 0px; }
body  { margin: 10mm 10mm 10mm 10mm; }
tbody > td > span { font-size: 14px !important; }

How can I force this table breaks to preserve margins?

Click on any element to print: /

I have a table that i want to print using JS window.print();. But when this table have too many lines oter pages dosen't preserve seted margins

My CSS:

@page { size:  auto; margin: 0px; }
html  { background-color: #FFFFFF; margin: 0px; }
body  { margin: 10mm 10mm 10mm 10mm; }
tbody > td > span { font-size: 14px !important; }

How can I force this table breaks to preserve margins?

Click on any element to print: https://jsfiddle/kfubawpg/

Share Improve this question asked Apr 6, 2017 at 17:35 gFontanivagFontaniva 90311 silver badges30 bronze badges 2
  • What do you mean exactly? The top-margin of the header on the following pages? – Legends Commented Apr 6, 2017 at 17:51
  • the margin-top and margin-bottom of breacked tables – gFontaniva Commented Apr 6, 2017 at 18:01
Add a ment  | 

2 Answers 2

Reset to default 4

You have the @page margin set to 0. Just change it to the size of the margin you want.

@page { size:  auto; margin: 50px; }

fiddle

You can do the following:

    @page :first { // set the margins for the first page in print mode
      margin: 100px;
    }

    @page { // set the margins for all following pages (tables) in print mode
    size:  auto; 
    margin-top: 10px;
    margin-bottom: 10px;
    }

Here is a demo

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745040104a4607757.html

相关推荐

  • javascript - JS window print margins breaked table - Stack Overflow

    I have a table that i want to print using JS window.print();.But when this table have too many lines o

    9小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信