I working with my project for printing some documents.There I met some problem in set header for each print pages ! I want to print the html table that have so many tr
,its separated to two pages when print.Therefore,I want to set thead
as header element for each print page.So help me !!
<style type="text/css">
table {
border: 1px solid #eee;
width: 100%;
color : green;
}
th,td {
border: 1px solid red;
width: 50px;
height: 50px;
}
@media print {
body * {visibility: hidden;}
#printable * {visibility: visible;}
#printable th {
top: 0;
}
}
</style>
<div id="printable">
<span><center>Print Example</center></span>
<table>
<thead>
<tr><th>Name</th>
<th>Salary</th>
<th>Phone</th>
</tr>
</thead>
<tbody>
<tr><td>David</td>
<td>3828</td>
<td>83939</td>
</tr>
<tr><td>Jone</td>
<td>39393</td>
<td>0202022</td>
</tr>
<tr><td>Smith</td>
<td>39000383929</td>
<td>0101010101</td>
</tr>
<tr><td>Sheee</td>
<td>3483939</td>
<td>111111</td>
</tr>
<tr><td>David</td>
<td>3828</td>
<td>83939</td>
</tr>
<tr><td>David</td>
<td>3828</td>
<td>83939</td>
</tr>
<tr><td>David</td>
<td>3828</td>
<td>83939</td>
</tr>
<tr><td>David</td>
<td>3828</td>
<td>83939</td>
</tr>
<tr><td>Jone</td>
<td>39393</td>
<td>0202022</td>
</tr>
<tr><td>Smith</td>
<td>39000383929</td>
<td>0101010101</td>
</tr><tr><td>Jone</td>
<td>39393</td>
<td>0202022</td>
</tr>
<tr><td>Smith</td>
<td>39000383929</td>
<td>0101010101</td>
</tr><tr><td>Jone</td>
<td>39393</td>
<td>0202022</td>
</tr>
<tr><td>Smith</td>
<td>39000383929</td>
<td>0101010101</td>
</tr><tr><td>Jone</td>
<td>39393</td>
<td>0202022</td>
</tr>
<tr><td>Smith</td>
<td>39000383929</td>
<td>0101010101</td>
</tr><tr><td>Jone</td>
<td>39393</td>
<td>0202022</td>
</tr>
<tr><td>Smith</td>
<td>39000383929</td>
<td>0101010101</td>
</tr>
</tbody>
</table>
</div>
Here I also want thead
to page 2 when print.(Running on Chrome)
This can be done setting a CSS property for the thead element of the html table. The property that needs to be set is: display: table-header-group. The following html table will repeat the table header at the top of each pdf page when converted to pdf.
CSS. Control the look and feel of the header and footer of your site with your CSS. To edit your CSS, click "Edit" at the right of the "Custom Header / Footer CSS" field under the "Appearance" tab of your Management Console.
ⓘ thead – table heading group. The thead element represents the block of rows that consist of the column labels (headings) for its parent table element.
Most browser do repeat <thead>
& <tfoot>
including chrome latest browsers.
still there is way you can make the thead repeat like below.
<thead class="report-header">
<tr>
<th>
<div class="header-info">
...
</div>
</th>
</tr>
</thead>
And you need to provide css like:
@media print {
thead.report-header {
display: table-header-group;
}
}
You can find detail description on below link.
repeat header
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With