【发布时间】:2017-10-24 13:58:00
【问题描述】:
我正在尝试使用一些很长的表格制作可打印的文档。有时页面在表头和数据之间结束,这使得它更难阅读。
我怎样才能防止这种情况发生?
我尝试使用以下 CSS,但没有帮助。
@media print {
h1, h2, h3, thead, thead>tr {
page-break-after: avoid;
page-break-inside: avoid;
}
tbody {
page-break-before: avoid;
}
/* I would also like to not have page breaks within first five rows */
tbody:nth-child(-n+5) {
page-break-before: avoid;
}
}
表结构:
<table border="1" cellspacing="0" cellpadding="3">
<thead>
<tr>
<th rowspan="2">Metric</th>
<th colspan="3">Type 1</th>
<th colspan="3">Type 2<th>
</tr>
<tr>
<th>Initial</th>
<th>Final</th>
<th>Difference</th>
<th>Initial</th>
<th>Final</th>
<th>Difference</th>
</tr>
</thead>
<tbody>
<tr>
<td>Dataset1</td>
<td>*DATA*</td>
...
</tr>
</tbody>
</table>
【问题讨论】:
标签: html css html-table