- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我有一个元素需要打印一个包含许多行的 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>
最佳答案
您可以通过实现 PHP 来实现这一目标。当我开始使用 PHP 时,我的导师只是让我们使用 PHP 创建一个“Web 模板”。此"template"将确保页面相似并具有一致的页眉、导航、页脚等。
您可以创建一个文件 (thead.php),其中包含您要重复的所有代码。我假设您想重复 <thead></thead>
之间的内容
(thead.php)
<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>
(你的文件.php)
<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>
<?php include 'thead.php'; ?>
<tbody>
<div id="contents">
<!--more then 800 rows in table-->
</div>
</tbody>
</table>
</div>
这将导致您必须将文件类型更改为 .php 并且您将不得不使用本地服务器进行测试,因为浏览器无法处理 .php 文件。我个人使用 XAMPP,但我确信还有许多其他选择。
如果您还不知道任何 php,它所做的基本上是根据通过您的 .PHP 文件中的脚本提供给它的信息为您编写一个 HTML 文件。当文件通过服务器运行后到达浏览器时,它只是可以处理和显示的简单 HTML 代码。因此,如果您按照我向您展示的方式进行操作,到达浏览器的最终文件不会有任何不同,只是您需要编写的代码更少。
关于html - 打印时使用 css 在每页上重复页眉,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39079512/
在 HTML5 中,是否可以创建仅供单个网页访问的本地存储? 我目前正在尝试编写独立的单页应用程序的可能性,以及用户是否可以自己托管它们,例如在他们的 Dropbox(它有一些公共(public)文件
我正在考虑在我的网站上转换广告的选项,并认为我会从 Google Adsense 开始 - 但是我不确定每页实际上可以有多少广告。我猜可以将横幅与说广告块等混合和匹配 - 那么您可以在单个页面上拥有的
我使用 Jekyll 创建了我的博客。有人告诉我,我的网站正在为某些页面编制 3 个 URL 的索引,这将被归类为 Google 的重复内容。我注意到我可以访问: https://villaagogo
我正在将 sitemesh 用于基于 spring 的站点。问题是我有一些 javascript,我希望它使用 jquery 在一个特定页面的 onload 事件上运行 $(function() {
我有一个分页脚本,它显示所有页面的列表,如下所示: 上一个 [1][2][3][4][5][6][7][8][9][10][11][12][13][14] 下一个 但我想一次只显示十个数字: 上一个
我在 Asp.Net 网站上工作。目前,我正在为每个页面(加载时)创建(并关闭)一个数据库连接。但我不确定,那是真正的方法。我想知道,如果我在静态类或 WebApplication 的主 Global
我想要的是:给定一个 10 页的 pdf 文件,我想在网络上的表格中显示该 pdf 的每一页。实现这一目标的最佳方法是什么?我想一种方法是将这个 10 页 pdf 文件拆分为 10 个 1 页 pdf
我网站的不同页面有不同的 js 需求(主要是插件),有些需要灯箱,有些不需要,有些需要轮播,有些不需要等等。 关于页面加载速度我应该 选项 1 - 在需要时引用每个 js 文件: 所以一页可能有:
我正在使用 Ionic2 slider ,来自其组件:http://ionicframework.com/docs/v2/api/components/slides/Slides/ .我不知道如何让
我正在尝试从 CsrfGuard.properties 启用 token 标准页面。但部署后,当我尝试访问 URL 时,我收到 500 错误,因为它抛出以下异常。 你能帮我解决这个问题吗?我需要在哪里
我是一名优秀的程序员,十分优秀!