Sea*_*nJA 3 html printing firefox
我有一张桌子,有a <thead>,a <tfoot>和a <tbody>.它应该在理论上打印每页上的thead和tfoot,但由于某种原因,如果它包含某些元素,那么它就不会.
这有效:
<thead>
<tr>
<td colspan="3">This works</td>
<tr>
<tr>
<th colspan="2">column 1</th>
<th>
column 2
</th>
</tr>
</thead>
Run Code Online (Sandbox Code Playgroud)
这似乎不起作用:
[编辑]
<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>
Run Code Online (Sandbox Code Playgroud)
[/编辑]
它打印:
[page 1]
[header]
[body]
[footer]
[page 2,3,4,5]
[body]
[footer]
Run Code Online (Sandbox Code Playgroud)
有没有理由不这样做?
在你的打印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*/
}
Run Code Online (Sandbox Code Playgroud)
根据您的需求进行调整
更新
在获取最新的HTML并使用它之后,我发现在每个页面上重复的内容都有一个高度限制.
我改变THEAD包含:
<tr><td><div style="min-height:251px;">Hello World</div></td></tr>
Run Code Online (Sandbox Code Playgroud)
如果我重复THEAD(已更改)和TFOOT(原样)......我只能使用高达251px的高度.试图进入任何更高的高度会导致THEAD部分不再重复.
我将保存关于这是一个功能还是一个错误的"辩论"...但我认为如果你有一个高于250px的重复标题,它可能会从一些收缩中受益.;-)