Home > Software engineering >  How to add a footer to the last part of the page when printing html
How to add a footer to the last part of the page when printing html

Time:03-20

I am using an html and css and I want to print it on the browser, I want to print the footer only on the last page of the page. Using the position: fixed will make the footer be visible on every page. How can I apply it only on the last page.

CodePudding user response:

Put the class div on your last page. see if this works

.last_page {
    page: last_page;
    page-break-before: always; 
}

@page {
   @bottom-right {
       content: "Please turn over";
    }
}

@page last_page {
    @bottom-right {
        content: none;
    }
}
<div ></div>

CodePudding user response:

Use css media print and page-break-before

window.print();
@media print{
#break{
page-break-before: always;
}
}
<div>Stack Overflow is a question and answer website for professional and enthusiast programmers. It is the flagship site of the Stack Exchange Network,[4][5][6] created in 2008 by Jeff Atwood and Joel Spolsky.[7][8] It features questions and answers on a wide range of topics in computer programming.[9][10][11] It was created to be a more open alternative to earlier question and answer websites such as Experts-Exchange. Stack Overflow was sold to Prosus, a Netherlands-based consumer internet conglomerate, on 2 June 2021 for $1.8 billion.[12]

The website serves as a platform for users to ask and answer questions, and, through membership and active participation, to vote questions and answers up or down similar to Reddit and edit questions and answers in a fashion similar to a wiki.[13] Users of Stack Overflow can earn reputation points and "badges"; for example, a person is awarded 10 reputation points for receiving an "up" vote on a question or an answer to a question,[14] and can receive badges for their valued contributions,[15] which represents a gamification of the traditional Q&A website. Users unlock new privileges with an increase in reputation like the ability to vote, comment, and even edit other people's posts.[16]</div>
<div id='break'>Break item</div>

  • Related