【发布时间】:2018-05-11 08:46:48
【问题描述】:
我做了一个简单的 html 页面,带有一点 CSS(在 CSS 中不是很好)来显示页眉和页脚之间的数据,但是当我在中间创建一个包含长数据的表格数据时,它与页脚重叠并且下一页的标题。下面是代码:
<html>
<head>
<style>
p { page-break-after: always; }
.footer { position: fixed; bottom: 0px; }
.header { position: fixed; top: 0px; }
</style>
</head>
<body>
<div class="header">this is the header</div><br>
<!-- <p>lorem ipsum ...</p><br>
<p>lorem ipsum ...</p><br>
<p>lorem ipsum ...</p><br>
<p>lorem ipsum ...</p> -->
<table style="width:100%">
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Age</th>
</tr>
<tr>
<td>Jill</td>
<td>Smith</td>
<td>50</td>
</tr>
<tr>
<td>Eve</td>
<td>Jackson</td>
<td>94</td>
</tr>
<tr>
<td>John</td>
<td>Doe</td>
<td>80</td>
</tr>
</table>
<div class="footer">this is the footer</div>
</body>
</html>
这是输出:
但如果我使用<p> CSS 来做,我认为它可以很好地使用此代码:
<html>
<head>
<style>
p { page-break-after: always; }
.footer { position: fixed; bottom: 0px; }
.header { position: fixed; top: 0px; }
</style>
</head>
<body>
<div class="header">this is the header</div><br>
<p>lorem ipsum ...</p><br>
<p>lorem ipsum ...</p><br>
<p>lorem ipsum ...</p><br>
<p>lorem ipsum ...</p>
<div class="footer">this is the footer</div>
</body>
</html>
和输出:
如何在页脚之前显示表格数据并在下一页页眉之后继续?
【问题讨论】:
-
这个输出是从哪里来的? PDF 转换器?
-
目前我对其进行了硬编码,但稍后我将使用 PHP 从数据库中调用数据。它要打印报告
-
没有你的 CSS 坏了,因为标题浮动在内容的顶部。
标签: php html laravel html-table