2010-03-22 37 views
0

我有一张桌子,上面有<thead><tfoot><tbody>。理论上应该在每一页上打印thead和tfoot,但是由于某种原因,如果它包含某些元素在一起,则不会。是否有任何限制使它不能在Firefox的每个页面上打印?

这工作:

<thead> 
    <tr> 
     <td colspan="3">This works</td> 
    <tr> 
    <tr> 
     <th colspan="2">column 1</th> 
    <th> 
     column 2 
     </th> 
</tr> 
</thead> 

这似乎并不工作:

[编辑]

<table> 
    <thead> 
     <tr> 
      <td colspan="3"> 
       <h2>Header</h2> 
        <address> 
         <strong>address 1</strong> <br /> 
         address 2 <br /> 
         address 3 <br /> 
        </address> 
       <img src="http://upload.wikimedia.org/wikipedia/commons/thumb/b/b7/Wikipedia-logo.svg/600px-Wikipedia-logo.svg.png" alt="Logo" /> 
       <h2>Another header</h2> 
       <hr /> 
      </td> 
     </tr> 
     <tr> 
      <th colspan="2">column 1</th> 
     <th> 
      column 2 
      </th> 
    </tr> 
    </thead> 
    <tfoot> 
     <tr> 
      <td>This is the footer</td> 
      <td>Column 2</td> 
      <td>Column 3</td> 
     </tr> 
    </tfoot> 
    <tbody> 
     <?php for ($i = 0; $i < 100; $i ++): ?> 
     <tr> 
      <td>Col 1</td> 
      <td>Col 2</td> 
      <td>Col 3</td> 
     </tr> 
     <?php endfor; ?> 
    </tbody> 
</table> 

[/编辑]

它打印:

[page 1] 
    [header] 
    [body] 
    [footer] 

[page 2,3,4,5] 
    [body] 
    [footer] 

有没有这个原因不起作用?

+0

你可以发布信息和示例如何不起作用?发生什么事? – 2010-03-22 15:52:18

+0

恐怕浏览器(甚至Firefox)不能正确地实现所有关于表格的HTML规则。 – 2010-03-25 15:39:01

+0

这似乎是这样的... – SeanJA 2010-03-25 17:11:22

回答

5

在打印CSS补充一点:

thead{ 
    display:table-header-group;/*repeat table headers on each page*/ 
} 
tbody{ 
    display:table-row-group; 
} 
tfoot{ 
    display:table-footer-group;/*repeat table footers on each page*/ 
} 

调整,以满足您的需求

更新

把你最新的HTML和摆弄它之后,我发现有是每个页面上重复的内容的高度限制。

我改变了THEAD包含:

<tr><td><div style="min-height:251px;">Hello World</div></td></tr> 

如果我重复THEAD(如改变)和TFOOT(这是)......我可以用一个高度最多只能251px。试图去任何更高的高度导致THEAD部分不重复。

我将保存关于这是功能还是bug的“辩论”......但我认为如果您的重复标题高于250像素,它可能会从某些缩小中受益。 ;-)

+0

我有thead和tfoot的样式,并且它们在IE 7中工作正常,但Firefox仍然有问题。 – SeanJA 2010-03-22 17:12:54

+0

您是否正确定义了您的HTML?例如[表] [THead /] [TFoot /] [Tbody /] [/表](以此顺序,例如脚在身体之前) – scunliffe 2010-03-22 19:08:33

+0

[表] [thead] [tfoot] [tbody] [/ table]是的,这就是为什么这使我困惑。 – SeanJA 2010-03-23 12:46:50