【问题标题】:JS window print margins breaked tableJS窗口打印边距破表
【发布时间】:2017-04-06 17:35:07
【问题描述】:

我有一张表格,我想使用 JS window.print(); 打印。 但是当这个表有太多的行以外的页面不会保留设置的边距

我的 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; }

如何强制此表格中断以保留边距?

点击任意元素打印:https://jsfiddle.net/kfubawpg/

【问题讨论】:

  • 你到底是什么意思?以下页面标题的top-margin
  • 分页表的 margin-top 和 margin-bottom

标签: javascript jquery html css printing


【解决方案1】:

您已将@page 边距设置为 0。只需将其更改为所需的边距大小即可。

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

fiddle

【讨论】:

  • 这解决了我的问题
【解决方案2】:

您可以执行以下操作:

    @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

【讨论】:

    猜你喜欢
    • 2022-08-02
    • 2021-07-10
    • 2012-03-29
    • 1970-01-01
    • 2016-05-22
    • 2018-06-07
    • 2017-03-31
    • 1970-01-01
    相关资源
    最近更新 更多