1
我想用一些很長的表格來製作一個可打印的文檔。有時頁面會在表格標題和數據之間結束,這使得閱讀變得更加困難。如何避免<thead>和<tbody>之間的分頁符
我怎麼能預防呢?
我試過使用下面的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>