Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS Print page footer only on last page

Tags:

html

css

printing

First of all, I've searched SO and there is no working solution

I have some long content, and I want to have footer only on last page. I tired:

1)

.footer{       
    position: absolute;
    bottom: 0;
}

If puts footer at the end of first page only.

2) As old answers suggest

@page :last

But :last doesn't exist (as I see from old answer it existed).

3) Normal footer, sure it is shown on the end of all pages.

How can I achieve this, footer only on last page ?

like image 216
Misha Akopov Avatar asked Oct 22 '25 17:10

Misha Akopov


1 Answers

You can try wrapping your header and content in a container with min-height:100vh. This should push your footer to the very bottom.

main {
  min-height: 100vh;
}
<main>
  <h1> The Header </h1>
  <p> The Content </p>
</main>
<footer>
  The Footer
</footer>
like image 156
WY34 Avatar answered Oct 25 '25 07:10

WY34



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!