Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fixed Sticky footer for PRINT only for last page

What I have is a <table> it can be big or small sometimes only on one page and sometimes it can grow to be 10 pages and so.

Here is a sample code:

div{
  position:relative;
  height:100vh;
}

.table-blue{
  width:100%;
  background:lightblue;
}

.table-blue td{
  padding:5px 10px;
}

.table-blue-fotter{
    position: absolute;
    bottom: 20px;/* for bottom gap */
    left: 0px;
    width:100%;
    background:gray;
}


@media print {
 .table-blue-fotter{
    position: fixed;
    bottom: 20px;
    left:0px;
    width:100%;
    background:gray;
}
<div>
<table class="table-blue">
  <tr>
    <td>one</td>
    <td>one test</td>
  </tr>
  <tr>
    <td>two</td>
    <td>two test</td>
  </tr>
  <tr>
    <td>three</td>
    <td>three test</td>
  </tr>
</table>

<table class="table-blue-fotter">
  <tr>
    <td>one</td>
    <td>one test</td>
    <td>one test</td>
  </tr>
  <tr>
    <td>two</td>
    <td>two test</td>
    <td>one test</td>
  </tr>
  <tr>
    <td>three</td>
    <td>three test</td>
    <td>one test</td>
  </tr>
</table>

</div>

Fiddle for property inspection - this workes good for me. But if the table gets long the story will change to this.

In the second view when the first <table> gets long, in the print view the footer appears on every page.

So what I want is to the .table-blue-fotter to appear only on the last page of the print view in the page bottom edge no matter the content height is.

enter image description here

only on Last page

Hopping for a CSS fix.

like image 754
Jithin Raj P R Avatar asked Feb 16 '18 14:02

Jithin Raj P R


People also ask

How do I print the footer on the last page only in HTML?

Try print mode in chrome and you can see that the footer now appears on the last page only at the bottom of the page. position: fixed in print mode makes the footer appear on all the pages at the bottom of every page. Here is the full screen view of the fiddle result. fiddle.jshell.net/ur6d1h21/12/show.

How do I put the footer at the bottom of the last page only?

You can do that by putting a Section Break (Menu Bar > Insert > Break... > Section Break Next Page) at the end of the page prior to the last page of the document. Make sure the last page's footer is Unlinked from the prior page's footer. You do that from the Header and Footer contextual ribbon tab in the Options Group.

How do I put the footer at the bottom without a fixed position?

CSS “Always on the bottom” Footer This is to prevent the footer from overlapping the content above it, since it is being removed from the document flow with position: absolute; . This footer will always be positioned at the bottom of the page, but not fixed.


1 Answers

Update following way:

@media print {
  .table-blue-fotter {
    position: static; /* <-- Key line */
    bottom: 20px;
    left: 0px;
    width: 100%;
    background: gray;
  }
like image 170
Hanif Avatar answered Oct 16 '22 22:10

Hanif