2012-07-12 28 views
0

這是我的問題。它類似於我在這裏看到的一些(即CSS: Repeat Table Header after Page Break (Print View)),但有一個區別:多個標頭在分頁符後顯示當前表格標題html

如何在動態表中斷點後顯示pagepbreak(在打印預覽模式下)發生的當前表頭?

所以,如果這是我的表和分頁符第二集後發生......

<table> 
    <tr><th>Head Cell 1a</th><th>Head Cell 2a</th><th>Head Cell 3a</th></tr> 
    <tr><td>Cell 1a</td><td>Cell 2a</td><td>Cell 3a</td></tr> 
    <tr><td>Cell 4a</td><td>Cell 5a</td><td>Cell 6a</td></tr> 

    <tr><th>Head Cell 1b</th><th>Head Cell 2b</th><th>Head Cell 3b</th></tr> 
    <tr><td>Cell 1b</td><td>Cell 2b</td><td>Cell 3b</td></tr> 

    <!--PAGE BREAK HERE ON PRINT PREVIEW--> 
    <tr><td>Cell 4b</td><td>Cell 5b</td><td>Cell 6b</td></tr> 
</table> 

...我希望能夠以顯示第二頭(頭細胞1B,2B, & 3b)作爲分頁符後的標題。換句話說,我想在分頁發生後顯示相應的標題,無論它發生在哪裏。所以上面的表格看起來應該是這樣的分頁符後...

<table> 
    <tr><th>Head Cell 1a</th><th>Head Cell 2a</th><th>Head Cell 3a</th></tr> 
    <tr><td>Cell 1a</td><td>Cell 2a</td><td>Cell 3a</td></tr> 
    <tr><td>Cell 4a</td><td>Cell 5a</td><td>Cell 6a</td></tr> 

    <tr><th>Head Cell 1b</th><th>Head Cell 2b</th><th>Head Cell 3b</th></tr> 
    <tr><td>Cell 1b</td><td>Cell 2b</td><td>Cell 3b</td></tr> 

    <!--PAGE BREAK HERE ON PRINT PREVIEW--> 
    <tr><th>Head Cell 1b</th><th>Head Cell 2b</th><th>Head Cell 3b</th></tr> 
    <tr><td>Cell 4b</td><td>Cell 5b</td><td>Cell 6b</td></tr> 
</table> 

我曾嘗試在<thead>標籤包裝的標題,然後我的CSS設置爲:

table, tr{page-break-after:auto;} 
thead {display:table-header-group;} 

但第一頭保持在每一頁上重演,所以我所看到的是這樣的:

<table> 
    <thead><tr><th>Head Cell 1a</th><th>Head Cell 2a</th><th>Head Cell 3a</th></tr></thead> 
    <tr><td>Cell 1a</td><td>Cell 2a</td><td>Cell 3a</td></tr> 
    <tr><td>Cell 4a</td><td>Cell 5a</td><td>Cell 6a</td></tr> 

    <thead><tr><th>Head Cell 1b</th><th>Head Cell 2b</th><th>Head Cell 3b</th></tr></thead> 
    <tr><td>Cell 1b</td><td>Cell 2b</td><td>Cell 3b</td></tr> 

    <!--PAGE BREAK HERE ON PRINT PREVIEW--> 
    <thead><tr><th>Head Cell 1a</th><th>Head Cell 2a</th><th>Head Cell 3a</th></tr></thead> 
    <tr><td>Cell 4b</td><td>Cell 5b</td><td>Cell 6b</td></tr> 
</table> 

如有的人在那裏可以與此問題的幫助,讓我儘快知道。我真的很感激它!

在此先感謝!

回答

0

首先在一個表格中不能有多個<thead>標籤。所以我必須做的是讓每個部分都是一個自己的表格,它有自己的<thead>。現在在分頁符後顯示正確的標題。