2017-08-08 130 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