避免分页在表中的行 [英] avoid page break inside row of table

查看:153
本文介绍了避免分页在表中的行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望避免在html中的表格中出现分页符,当我通过wkhtmltopdf将html转换为PDF时。我使用page-break-inside:避免与table-它的工作,但我有这么多行,
然后不工作。
如果将 tr显示为块或其他东西,则它会更改表格的格式并插入双边框。

I want to avoid page break inside row of table in html, when I convert html to PDF by wkhtmltopdf. I use page-break-inside:avoid with table- its works, but I have so many rows, then not work. If set display of tr as block or some thing else then it change the formatting of table and insert double border. Or it is possible to insert the table header on each page, where the table was splitted.

推荐答案

您可能需要请尝试使用CSS:

You might try this with CSS:

<table class="print-friendly">
 <!-- The rest of your table here -->
</table>

<style>
    table.print-friendly tr td, table.print-friendly tr th {
        page-break-inside: avoid;
    }
</style>

大多数CSS规则不适用于< tr> 标签,因为正是你在上面指出的 - 它们有一个独特的显示样式,不允许这些CSS规则。但是,< td> < th> 标记中通常允许这种规范 - 你可以很容易地将这样的规则应用到所有的孩子 - < tr> '和< td> 使用CSS如上所示。

Most CSS rules don't apply to <tr> tags directly, because of exactly what you pointed out above - they have a unique display style, which doesn't allow for these CSS rules. However, the <td> and <th> tags within them usually do allow this kind of specification - and you can easily apply such rules to ALL child-<tr>'s and <td>'s using CSS as shown above.

这篇关于避免分页在表中的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆