Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you place a footer at the bottom of the LAST page when there is dynamic data in the body

Tags:

html

css

I am trying to create a report which has a requirement that the footer must be placed at the bottom of the last page. The report body loads dynamically based off how many records are returned from the database. The report could be 1 page or more.

I have tried using a sticky footer, this is OK for viewing the HTML on the website but when the length of the report is greater than 1 page and when viewing the print preview screen, the footer overlaps with the body of the report and the footer remains on the first page instead of moving to the last page.

Does anyone know of a way to place a footer at the bottom of the last page when creating a printable screen that is properly formatted for a user to print without using a sticky footer.

The sticky footer I implemented did not display properly in the print preview screen when there was multiple pages to print.

like image 202
Telecaster Avatar asked Feb 05 '13 18:02

Telecaster


People also ask

How do I get my footer to the bottom of the page?

The trick is to use a display:table for the whole document and display:table-row with height:0 for the footer. Since the footer is the only body child that has a display as table-row , it is rendered at the bottom of the page.

How do I stick footer to the bottom when page content is less?

Quick answer: Add “display:flex; flex-direction:column; min-height:100vh;” to body or appropriate layout body element, then add “flex:1;” to content wrapper element/section.


1 Answers

CSS

#sticky-footer 
{
    position: fixed;
    bottom: 0px;
}
@media print 
{
    #sticky-footer 
    {
        position: static;
        bottom: auto;
    }
}

HTML

<div id="report-content">...</div>
<div id="sticky-footer">...</div>
like image 82
Louis Ricci Avatar answered Sep 24 '22 17:09

Louis Ricci