【问题标题】:Avoid pagebreak in one table row while printing打印时避免在一个表格行中出现分页符
【发布时间】:2018-08-20 21:32:14
【问题描述】:

我创建了一些 PHP 脚本,调用它来打印。但是,不幸的是我有一个小问题..

您可以在照片中看到问题:

当第一个 TD 中的文本在最后一页并且第二个和第三个 TD 中的图片在新页面时,我需要保护这个分页符。

我尝试使用

page-break-inside: 避免 !important;

空白:nowrap;

...但没有帮助

这是我的表格 CSS。

table.prvni {
        margin: 100px 10px 0px 10px;
        padding-bottom: 50px;
        page-break-inside: avoid !important;
    }
  caption {
        text-align: left;
        font-weight: 600;
        font-size: 13px;
        padding-bottom: 15px;
    }

    th:first-child {
        width: 250px;
        padding: 3px 6px;
    }

    th:last-child {
        width: 200px;
        padding: 3px 3px;
    }

    th {
        width: 200px;
        padding: 3px 6px;
    }

    tr:first-child {
        background: #ecefef;
        font-size: 13px;
        font-weight: 600;
    }

    tr {
        background: #f7fafa;
        font-size: 11px;
        font-weight: 400;
    }

    td:first-child {
        text-align: justify;
        font-size: 12px;
        font-weight: 400;
        font-style: normal;
    }

    td:last-child {
        font-style: normal;
        font-weight: 400;
        font-size: 12px;
    }

    td {
        font-style: italic;
        font-size: 12px;
        text-align: center;
    }

有人可以帮忙吗?

【问题讨论】:

    标签: php css row css-tables page-break


    【解决方案1】:

    解决了。

    只需更改 CSS,重要的是分页参数。

     table.prvni {
       margin: 100px 10px 0px 10px;
       padding-bottom: 50px;
       page-break-inside:auto;
       page-break-after: always;
     }
     table.druha {
       margin: 50px 10px 0px 10px;
       padding-bottom: 50px;
       page-break-inside:auto;
     }    
     caption {
       text-align: left;
       font-weight: 600;
       font-size: 13px;
       padding-bottom: 15px;
     }    
     th:first-child {
       width: 250px;
       padding: 3px 6px;
     }    
     th:last-child {
       width: 200px;
       padding: 3px 3px;
     }    
     th {
       width: 200px;
       padding: 3px 6px;
     }    
     tr {
       background: #f7fafa;
       font-size: 11px;
       font-weight: 400;
       page-break-inside:avoid;
       page-break-after:auto;
     }    
     td:first-child {
       text-align: justify;
       font-size: 12px;
       font-weight: 400;
       font-style: normal;
     }    
     td:last-child {
       font-style: normal;
       font-weight: 400;
       font-size: 12px;
     }    
     td {
       font-style: italic;
       font-size: 12px;
       text-align: center;
     }    
     #maly {
       font-style: normal;
       font-weight: 400;
       font-size: 10px;
     }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-01-02
      • 1970-01-01
      • 2012-03-06
      • 1970-01-01
      • 2011-07-05
      • 2018-07-03
      • 2011-10-12
      相关资源
      最近更新 更多