的page-break-inside: avoid
財產應該控制這一點,但它看起來像大多數的瀏覽器不支持對tr
或td
元素。在我的測試,Opera是既尊重這個屬性,如下面的測試中使用的只有一個:
<!DOCTYPE html>
<title>Page Break Test</title>
<style>tr, td { page-break-inside: avoid }</style>
<table border=1>
<tr height=200><td>This is a test. This should be tall.<td>Another column.
<tr height=200><td>This is a test. This should be tall.<td>Another column.
<tr height=200><td>This is a test. This should be tall.<td>Another column.
<tr height=200><td>This is a test. This should be tall.<td>Another column.
<tr height=200><td>This is a test. This should be tall.<td>Another column.
<tr height=200><td>This is a test. This should be tall.<td>Another column.
<tr height=200><td>This is a test. This should be tall.<td>Another column.
<tr height=200><td>This is a test. This should be tall.<td>Another column.
<tr height=200><td>This is a test. This should be tall.<td>Another column.
<tr height=200><td>This is a test. This should be tall.<td>Another column.
<tr height=200><td>This is a test. This should be tall.<td>Another column.
<tr height=200><td>This is a test. This should be tall.<td>Another column.
<tr height=200><td>This is a test. This should be tall.<td>Another column.
<tr height=200><td>This is a test. This should be tall.<td>Another column.
<tr height=200><td>This is a test. This should be tall.<td>Another column.
<tr height=200><td>This is a test. This should be tall.<td>Another column.
</table>
如果你可以使用Opera,這可能是不夠好。另一種方法是查看Prince是否打印報告,因爲它比瀏覽器更容易支持打印樣式表功能(儘管我沒有特別測試過這個功能)。
我希望CSS能夠更好地處理打印表格,但它似乎不能很好地處理CSS分頁符選項。我也想看看這個解決方案。 –
對於答覆的遲到表示抱歉,已經過了短暫的假期。在仔細考慮之後,我決定給Brian一個答案,因爲他通過他的測試發現了一些有趣的結果,並提出了與Prince合作的解決方案。我還標記markjgrant的答案,因爲這是一個可能的解決方案,通過黑客,我沒有想到。 – Alex