【发布时间】:2016-12-29 00:05:19
【问题描述】:
我有一个项目需要打印一个多行的 HTML 表格。我想在每一页的顶部显示thead 部分。我用的是IE11浏览器。
<style>
@media print {
#Header {
display: table-header-group;
}
table {
page-break-inside: auto;
}
tr {
page-break-inside: auto;
position: static;
}
}
</style>
<div class="tab-pane active " id="template">
<table>
<thead>
<div id="Header">
<table style="width: 100%; table-layout: fixed;" id="tbl_1" class="table table-bordered">
<tbody>
<tr id="1">
<td style="height: 18px; border:solid; " ></td>
<td style="height: 18px; border:solid; "></td>
<td style="height: 18px; border:solid; "></td>
<td style="height: 18px; border:solid; "></td>
</tr>
<tr id="2">
<td style="height: 18px; border:solid; "></td>
<td style="height: 18px; border:solid; "></td>
<td style="height: 18px; border:solid; "></td>
<td style="height: 18px; border:solid; "></td>
</tr>
</tbody>
</table>
</div>
</thead>
<tbody>
<div id="contents">
<!--more then 800 rows in table-->
</div>
</tbody>
</table>
</div>
【问题讨论】:
-
这有帮助吗? HTML header/footer
-
您的 HTML 错误。表头应该有行而不是另一个表的 div。我是。不需要和媒体 css 重复表头。
-
您是否尝试将标题 id 设置为 position: fixed with top: 0?我知道这适用于某些实现。
标签: html css printing html-table