[英]Print CSS header at each page in a multi page document
Want to add a header on each page in the Printed document.想要在 Printed 文档的每一页上添加一个 header。
Used page-break-inside: avoid
, as if some portion of the content is going to next page, it should completely go to next page.使用page-break-inside: avoid
,好像部分内容要转到下一页,它应该完全go 到下一页。
The problem occurs when the content itself takes more than a page.当内容本身超过一页时,就会出现问题。 The table structure is表结构为
<table class="super-table">
<thead class="pageheader">
<tr>
<td>
<?php echo $header; ?>
</td>
</tr>
</thead>
<tbody>
<tr>
<td>
<?php echo $content[0]; ?>
</td>
</tr>
<tr>
<td>
<?php echo $content[1]; ?>
</td>
</tr>
</tbody>
<tfoot>
<tr>
<td>
<?php echo $footer; ?>
</td>
</tr>
</tfoot>
</table>
CSS CSS
@media print {
thead {
display: table-header-group; position: running(pageheader);
}
tr, td {
page-break-inside: avoid;
}
@page {
size: letter portrait;
@top-left { content: element(pageheader); }
}
.super-table {
page-break-after: always;
}
}
The header overlaps when the content takes up more than a page.当内容占用超过一页时,header 重叠。 Can I have a margin set for content only in each page and not the header?我可以只在每个页面中为内容设置边距,而不是 header? Adding margin-top to @page
shifts down the header also.将 margin-top 添加到@page
也会使 header 向下移动。
IMAGE: <thead>
overlaps if content occupies more than one page IMAGE: <thead>
重叠,如果内容占据超过一页
It has nothing to do with PHP but with CSS. 它与PHP无关,但与CSS无关。 PHP cannot manipulate with website design, it just outputs content. PHP无法通过网站设计来操作,它只能输出内容。
You are probably looking for this: Repeat table headers in print mode 您可能正在寻找: 在打印模式下重复表格标题
This can be done by the new page module of css.这可以通过 css 的新页面模块来完成。
But as this is not supported by browsers until now, you can have a look at paged.js .但由于到目前为止浏览器不支持此功能,您可以查看paged.js 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.