Footer on last printed page
Try to position the body relative and the footer absolute:
body {
position: relative;
}
#printfooter {
position: absolute;
bottom: 0;
}
With CSS 3 Paged Media module you could use something like this:
@page:last {
@bottom-center {
content: "…";
}
}
Print table footer at the very bottom on last page
If you're only supporting Firefox, this is actually really easy. (Skip to the edit to see a technique that also works in IE but is less versatile. Chrome and the other webkit browsers didn't support repeating footers when I posted this answer, so I didn't test them).
All you have to do is add a large bottom margin at the end of your content. The exact size doesn't matter, but it must be large enough to be guaranteed to run past the end of the page. I recommend making it at least as large as the maximum paper size you think your users will use.
Don't worry, this won't add a blank page to the end of your document. Margins differ from other forms of white space (such as padding and <br>
tags) in that they get cancelled out when they exceed the page boundary (see spec, section 13.3.3). Both Firefox and IE will delete the margin, but Firefox will still generate a footer at the bottom of the page as if a page break had occurred. (IE, on the other hand, behaves as if the margin was never there, which is why this approach doesn't work in that browser.)
You can put the margin on a pseudo-element to keep your HTML tidy, and you can use @media print
to prevent it from showing on screen.
Here's the code. To see it work in Firefox, open this jsfiddle, right-click the output, select This Frame > Show Only This Frame, and do a print preview.
@media print {
#content:after {
display: block;
content: "";
margin-bottom: 594mm; /* must be larger than largest paper size you support */
}
}
<table>
<thead>
<tr>
<th>PAGE HEADER</th>
</tr>
</thead>
<tfoot>
<tr>
<td>PAGE FOOTER</td>
</tr>
</tfoot>
<tbody>
<tr>
<td id="content">
content<br>content<br>content<br>content<br>content<br>content<br>content<br>
content<br>content<br>content<br>content<br>content<br>content<br>content<br>
content<br>content<br>content<br>content<br>content<br>content<br>content<br>
content<br>content<br>content<br>content<br>content<br>content<br>content<br>
content<br>content<br>content<br>content<br>content<br>content<br>content<br>
content<br>content<br>content<br>content<br>content<br>content<br>content<br>
content<br>content<br>content<br>content<br>content<br>content<br>content<br>
content<br>content<br>content<br>content<br>content<br>content<br>content<br>
content<br>content<br>content<br>content<br>content<br>content<br>content<br>
content<br>content<br>content<br>content<br>content<br>content<br>content
</td>
</tr>
</tbody>
</table>
How to fix the footer to make it positioned at the end of the page? (css print)
Try this CSS in print as you used.
.report-footer{
position: fixed;
bottom: 0;
background:red;
display: block;
width:100%;
}
<table class="report-container">
<thead class="report-header">
<tr>
<th>
<h1>Header</h1>
</th>
</tr>
</thead>
<tbody class="report-content">
<tr>
<td>
<!-- body -->
</td>
</tr>
</tbody>
<tfoot class="report-footer">
<tr>
<td>
<h1>Footer</h1>
</td>
</tr>
</tfoot>
</table>
Related Topics
CSS "D" Path - Attribute Doesn't Work in Safari, Firefox
When Does Flex-Grow Switch to Flex-Shrink, and Vice-Versa
In CSS Grid Why Is 1Fr+9Fr Not Behaving the Same as 10Fr in Small Screen Sizes
Nested Rows with Bootstrap Grid System
Line-Height as a Percentage Not Working
Less/Sass Debugging in Chrome Dev Tools/Firebug
Horizontally Centering/Evenly Distributed <Li> Inside of <Ul> Inside a <Div>
Set CSS Border Color to Text Color
CSS Transitions Between Absolute and Relative Positioning
How to Unskew Background Image in Skewed Layer (Css)
Table-Cell - Some Kind of Colspan
Why Does Width/Height Work on an Inline Img Element
CSS Pseudo-Element to Apply the First Character of an Element
Two Divs Next to Each Other, That Then Stack with Responsive Change
Removing the Ie10 Select Element Arrow
How to Standardize the Height of a Select Box Between Chrome and Firefox
Difference Between Width and Device-Width in CSS Media Queries