Footer to display exclusively on the final printed page's bottom

I am facing an issue with my certificate template. It contains dynamic content in the header, body, and footer sections. When printing a single page, everything looks fine. However, when printing multiple pages, the footer does not display at the bottom of the last page.

I have tried various CSS positioning options such as position: absolute, static, and fixed. The following code is the closest to achieving the desired outcome:

body {
  min-height: 100vh;
  margin: 0;
}

header {
  min-height: 50px;
  background: lightcyan;
}

footer {
  min-height: 50px;
  background: PapayaWhip;
}

body {
  display: flex;
  flex-direction: column;
}

article {
  flex: 1;
}

.h500 {
  height: 500px;
  border: 1px solid #DDD;
  margin: 2px;
}
<!DOCTYPE html>
<html>

<body>
  <header contentEditable>Header</header>
  <article contentEditable>
    <div class="h500">I set its height to 500px to span across two pages</div>
    <div class="h500">I set its height to 500px to span across two pages</div>
    <div class="h500">I set its height to 500px to span across two pages</div>
  </article>
  <footer contentEditable>Footer</footer>
</body>

</html>

Answer №1

Kindly make sure to adjust the footer css by including position:fixed; and also incorporate padding-bottom for the article based on your footer height.

body{min-height:100vh;margin:0;display:flex;flex-direction:column;position:relative;}
header{min-height:50px;background:lightcyan;}
footer{min-height:50px;background:PapayaWhip;position:absolute;bottom:0;width:100%;left:0;}
article{flex:1;padding-bottom:50px;}
.h500{height:90vh;border:1px solid #DDD;margin:2px; page-break-after: always;}
.h500:last-child{height:calc(100vh - 70px);}   
<!DOCTYPE html>
<html>
 <head> 
 </head>
 <body>

   <header contentEditable>Header</header>

   <article contentEditable>
      <div class="h500">I adjusted the height to display in multiple pages</div> 
      <div class="h500">I adjusted the height to display in multiple pages</div> 
      <div class="h500">I adjusted the height to display in multiple pages</div>   
   </article>

   <footer contentEditable>Footer</footer>

 </body>
</html>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Images in the Ionic app are failing to display certain asset files

Currently, I am working on an Ionic 4 app for both Android and iOS platforms. The issue I am facing is that only SVG format images are displaying in the slide menu, even though I have images in both SVG and PNG formats. public appPages = [ { ...

Saving HTML files can cause formatting issues

After creating a website with the web design tool "Nicepage", I noticed something strange. When visiting the site through this link: It appears to be working perfectly fine (please let me know if it isn't). The layout should resemble this image: htt ...

When collapsing an accordion, Bootstrap radio buttons fail to properly select

I have attempted various methods to achieve the desired functionality of having the accordion content close and open accordingly when checking a radio button, while also having the button visually appear as 'checked'. For a more in-depth example, ...

Struggling with CSS Flexbox when it comes to organizing rows and combining Table and Table Cells

I've been struggling to fix a CSS flex problem for hours. My goal is to make sure that the three boxes in each row have the same height. While I'm familiar with using flex, I suspect that floats may be the root of the issue. Even after clearing t ...

Form alignment issue: Bootstrap justify-content feature not functioning as expected

I am having trouble aligning my input form that is designed to capture Twitter handles in the center of the page. Despite using Bootstrap and ASP.NET, I cannot seem to get it to work as intended. Here is a snippet of the relevant CSS/HTML code: <form ...

The collapse button in Bootstrap 3.3 and jQuery 1.1 appears to be visible but unresponsive when clicked

This code isn't functioning properly as it displays the three horizontal bar button, but nothing happens when clicked. bootstrap-3.3 jquery-1.1 Toggle navigation CopyHere <div class="collap ...

The jQuery element selection feature is not functioning

Within my HTML file, there lies a table with an empty tbody that is dynamically filled by jQuery once the document is fully loaded. The content of the table body is generated using a PHP script, where jQuery fetches the data via a simple GET request. Belo ...

What is preventing Kohana from reading my CSS?

Recently, I launched my website kipclip.com on the Kohana platform and added a new rental page. However, the CSS and JS files are not being applied to this page. I've looked into how these files are included in Kohana but haven't had any luck so ...

Using CSS/HTML5 with either the :target or :active selector can allow for the display of different text content when a

Is it possible to change the text displayed on a website without reloading the page when a link is clicked? For instance, if I have an "About" or "Contact" link on my personal website, can the text in the body of the page be switched dynamically? In the i ...

The HTML body is given a right margin for proper spacing

Within the page, I noticed some margin to the right that extends beyond the body itself, causing a scroll bar to appear at the bottom. However, I'm unable to determine the root cause of this issue. I have provided links to both Codepen and Netlify be ...

HTML SVG text elements styled with varying background shades

Looking to enhance an image by adding multiple labels with distinct background colors: <!DOCTYPE html> <html> <head> <title>Page Title</title> </head> <body> <svg version="1. ...

Events Unavailable for Viewing - Full Calendar - Database Error Encountered

I am currently developing a calendar application. While I have managed to successfully display the calendar and add events, I am facing an issue with displaying events on the monthly view. Here is a snippet of the HTML code being used: <head> &l ...

I am struggling to link my JS application with a PHP file as it is showing "PHP file not found

I am facing an issue with my JS application. I am unable to send data from jQuery to a PHP file, as I encountered this error message: POST https://magazyn.rob-tech.pl/savesettings.php 404 The app is running on PORT=8080 npm run start and the package.json ...

Creating a dynamic image carousel using jQuery

Today, I completed the jQuery course on Code Academy and am now trying to create an image slider using it. While I have a general idea of how it should work, I feel like I'm missing a key element. My goal is to have the slider continuously running whe ...

Converting nested json objects to HTML format with the help of jQuery

I've been wracking my brain on this issue for quite some time and I just can't seem to crack it. After posting a question, I received some helpful answers and decided to implement the code provided in the second response (be sure to check out my ...

Updating the background of the <html> tag using jQuery

Is there a way to modify this CSS using jQuery? html { background: yellow; } Attempting the following code does not yield the desired results: $('html').css('background','red'); ...

Tips for determining the full width of a webpage, not solely the width of the window

While we can easily determine the width of the window using $(window).width(); This only gives us the width of the window itself, not accounting for any overflowing content. When I refer to overflowing, I mean elements that extend beyond the visible view ...

Tips for preloading icon font in Angular server-side rendering (SSR)

Is it possible to preload icons and fonts before the HTML content is rendered? I have been using a preload strategy to try and achieve this. index.html <!doctype html> <html lang="en"> <head> <meta charset="utf-8&quo ...

Enhancing the menu/navigation bar with individual AJAX loaders

I have chosen the Vivant Designs theme for our website, which can be found at What I am looking to achieve is an ajax loader that will appear next to the link or tab when a user clicks on a link within the drilldown menu located on the left side. The cont ...

Take the attention away from the canvas

Is there a way to shift focus away from the canvas and onto input fields in my HTML code? Right now, the canvas is holding onto focus even when I'm clicking on text inputs. This prevents me from typing anything into them. Ideally, I'd like for t ...