2017-08-08 128 views

回答

0

試試下面的CSS (如果你有一個非常簡單的THEAD的只有一個藏漢這不僅有助於)

thead { display: table-header-group } 
tfoot { display: table-row-group } 
tr { page-break-inside: avoid } 

編輯:

關於你的問題:你的thead重疊的原因是你的table標記本身。現在我們有多個tablethead,以及導致重疊的填充。我做了一些研究,發現了兩種不同的解決方案。


事實1:只有在打印時在你的標記的最新的thead會在第二頁上的地方。因此,您可以檢查和調整你的表像這樣working example here, print button on the top:如果你想在所有頁面上所有的THEAD信息是把所有th在在我看來唯一可行的解​​決方案:

<table> 
    <!-- thead on first page --> 
    <thead> 
     <tr> 
      <th> ... </th> 
     </tr> 
    </thead> 
    <tbody> 
     <tr> 
      <td> 
       <table> 
        <!-- thead on first page an all following --> 
        <thead> 
         <tr> 
          <th> ... </th> 
         </tr> 
        </thead> 

        <tbody> 
         <tr> 
          <td> ... </td> 
         </tr> 
        </tbody> 
       </table> 
      </td> 
     </tr> 
    </tbody> 
</table> 

事實2一個theadtable的頂部,因此您必須在每一頁上所有信息working example for this solution, print button on the top

希望這有助於:)

+0

的下面的CSS已經存在 @media打印{ THEAD {顯示:表頭基} TFOOT {顯示:表列的基團} TR {分頁-內:避免} } THEAD {顯示:table-header-group} tfoot {display:table-row-group} tr {page-break-inside:avoid} – Deepankar

+0

更新了我的答案,希望能讓它更清晰 –

+0

嗨,一旦我添加一行在嵌套表之前。錯誤又回來了。所以如果嵌套表是第一行的孩子,你的答案就工作了。 https://jsfiddle.net/epj3ebc8/2/ – Deepankar