如何在打印大型HTML表时处理分页符 [英] How to deal with page breaks when printing a large HTML table
本文介绍了如何在打印大型HTML表时处理分页符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个项目需要打印一个包含许多行的HTML表格。
I have a project which requires printing an HTML table with many rows.
我的问题是表格在多页上打印的方式。它有时会切成一排,使它不可读,因为一半在页的出血边缘,剩余部分打印在下一页的顶部。
My problem is the way the table is printed over multiple page. It will sometimes cut a row in half, making it unreadable because one half is on the bleeding edge of a page and the remainder is printed on the top of the next page.
我可以想到的唯一合理的解决方案是使用堆叠的DIV而不是一个表,并强制分页,如果需要..但在经历整个变化之前,我想我可以问这里之前。
The only plausible solution I can think of is using stacked DIVs instead of a table and force page-breaks if needed.. but before going through the whole change I thought I could ask here before.
推荐答案
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Test</title>
<style type="text/css">
table { page-break-inside:auto }
tr { page-break-inside:avoid; page-break-after:auto }
thead { display:table-header-group }
tfoot { display:table-footer-group }
</style>
</head>
<body>
<table>
<thead>
<tr><th>heading</th></tr>
</thead>
<tfoot>
<tr><td>notes</td></tr>
</tfoot>
<tbody>
<tr>
<td>x</td>
</tr>
<tr>
<td>x</td>
</tr>
<!-- 500 more rows -->
<tr>
<td>x</td>
</tr>
</tbody>
</table>
</body>
</html>
这篇关于如何在打印大型HTML表时处理分页符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文