表标题在打印时重复 [英] table heading repeat while printing

查看:206
本文介绍了表标题在打印时重复的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用表来显示记录列表。它有很多行和列。如果我打印此表,表标题显示在第一页。第一页后,标题不显示。我从Google搜索找到了很多网站。我遵循了这种方法,但我不能实现。我不能意识到错误。这是我的css。

I have used table for display the list of records. It have lot of rows and columns. If I print this table the table heading display in first page. After the first page the headings are not display. I found many website from Google search. I have followed that method, but I could not achieve. I could not realize the mistake. This is my css.

<style type="text/css" media="print" >
table td {
    border-bottom:1px solid gray;
}
th {
font-family:Arial;
color:black;
background-color:lightgrey;
}
thead {
    display:table-header-group;
}
tbody {
    display:table-row-group;
}
</style>

这是我的Html代码:

This my Html code:

<table border="0" cellpadding="2" cellspacing="0">
    <thead>
        <tr>
            <th>ID</th>
            <th>First Name</th>
            <th>Last Name</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td>1</td>
            <td>First Name 1</td>
            <td>Last Name 1</td>
        </tr>
    </tbody>
</table>

任何人都可以帮助我?

Anyone can help me? Thanks.

推荐答案

尝试将其添加到您的CSS中:

Try adding this in your CSS :

  @media print
 {
   thead {display: table-header-group;}
 }

这篇关于表标题在打印时重复的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆