【发布时间】:2018-07-27 11:57:40
【问题描述】:
我有一个<table>,它可以是big或small,有时只在一页上,有时它可以增长到 10 页等等。 p>
这是一个示例代码:
div{
position:relative;
height:100vh;
}
.table-blue{
width:100%;
background:lightblue;
}
.table-blue td{
padding:5px 10px;
}
.table-blue-fotter{
position: absolute;
bottom: 20px;/* for bottom gap */
left: 0px;
width:100%;
background:gray;
}
@media print {
.table-blue-fotter{
position: fixed;
bottom: 20px;
left:0px;
width:100%;
background:gray;
}
<div>
<table class="table-blue">
<tr>
<td>one</td>
<td>one test</td>
</tr>
<tr>
<td>two</td>
<td>two test</td>
</tr>
<tr>
<td>three</td>
<td>three test</td>
</tr>
</table>
<table class="table-blue-fotter">
<tr>
<td>one</td>
<td>one test</td>
<td>one test</td>
</tr>
<tr>
<td>two</td>
<td>two test</td>
<td>one test</td>
</tr>
<tr>
<td>three</td>
<td>three test</td>
<td>one test</td>
</tr>
</table>
</div>
Fiddle for property inspection - 这对我很有用。但如果表格变长,故事将变为this。
在第二个视图中,当第一个 <table> 变长时,打印视图页脚出现在每一页上。
所以我想要.table-blue-fotter 只出现在页面底部边缘的打印视图的最后一页上,无论内容高度如何。
仅在最后一页
期待CSS 修复。
【问题讨论】:
-
"在打印视图中,页脚出现在每一页上。"表示您的“每一页”在哪里,除了单页,我们看不到每一页。你能在这里澄清更多吗?
-
@Hanif “在每一页中”表示打印视图。如果你在 HTML 文件中使用 jsfiddle.net/jithinrajpr7/ur6d1h21 并单击
ctrl +p,那么你将获得不止一个打印视图的代码,并且你会看到“页脚出现在每一页上”。跨度>
标签: css printing html-table stylesheet