create a new div at the bottom of a designated page when printing out the content

I am facing a challenge with printing a table that has a variable number of rows via browsers. I need to ensure that the table is followed by a div which remains at the bottom of each page, adjusting its position according to the table's overflow onto subsequent pages. Initially, I tried implementing this using HTML as shown below:

.footer{
   width: 100%;
      position: absolute;
      bottom: 0;
      font-size: 10pt;
 }

However, this approach did not work as expected, as the footer remained on the first page. Any assistance would be greatly appreciated!

UPDATE

In an attempt to resolve the issue, I grouped the table and footer within a parent div so they could interact accordingly. This ensures that a footer always appears on the same page as the end of a table. Apologies for any confusion caused earlier!

SOLUTION [UPDATED]

After further adjustments, I was able to successfully address the problem by enclosing the footer within another div and applying the following CSS styling:

.table{
        min-height: 20cm !important;/* Set the height for the table in cm or mm (px and % resulted in issues) */
        display: block;
        position: relative;
        width: 100% !important;
    }
    .footer{
        width: 100%;
        position: relative;
        margin-bottom: 0 !important;
        font-size: 10pt;
        page-break-inside: avoid !important;
        page-break-before: auto !important; /* Moves the footer to the bottom of the next page if the table overflows */
    }

The only outstanding concern now is when the table perfectly fits the first page - the footer gets pushed to the top of the next page :( A big thank you to everyone who contributed their insights! :)

Answer №1

I managed to make the footer stay fixed at the bottom of the container and move along with it.

If you're looking to have the footer positioned at the end of the table, this is how I achieved it:

#footer {
    background-color: #333;
    clear:both;
    bottom: 0;
    width: 1200px;
    height: 50px;
    margin: 0 auto;
    border-radius:0px 0px 10px 10px;
}

For styling the paragraph inside the footer, use the following code:

#paragraph_1 {
    display:block;
    color:white;
    text-align:bottom-left;
    padding:14px 16px;
    text-decoration:none;
}

Answer №2

Consider implementing position: fixed; on this specific div.

When you specify bottom: 0, it will be positioned at the bottom of the printed page.

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

Are there any tools you rely on for speeding up the process of developing html/css?

Have you heard of zen-coding? It's a script that generates markup based on a css-esque selector like this: div#foo > p*6 This code would generate: <div id="foo"> <p></p> <p></p> <p></p> & ...

Align the inline text at the center as if it were an inline-block element

Currently working on a design that appears deceptively simple, yet I'm encountering challenges in centering it while keeping the text aligned to the left. https://i.sstatic.net/qhf6p.png In an attempt to have the background span only the actual text ...

Error Encountered: Bootstrap Dropdown Menu Malfunction in Master Page

I'm struggling to make my Bootstrap drop down menu function properly. Nothing happens when I click on the link, no dropdown appears. I've set up my nav bar in a master page and have spent hours trying to troubleshoot it without success... This i ...

The email message content is not displaying correctly

I'm in the process of merging multiple HTML tables into a single $message, which will then be passed to the email body as shown below. // Sending the email if(smtp_mail($To,$cc, $Subject, $message, $headers)) { echo "Email Sent"; } else { echo "An ...

Arrange the element as though it were the foremost

My specific scenario is as follows: <div id="container"> <p id="first">...</p> <p id="second">...</p> </div> I am looking to rearrange the order of second and first within the HTML stru ...

Various background positions

Is it possible to declare multiple background positions for the same background image? I have a span with the class page_heading and I want this class to display the same image twice, once at the beginning of the text and once at the end. HTML: <h1&g ...

Is there a way to verify if an element possesses a specific style, and if so, alter the style of a different element accordingly?

Could you assist me in achieving a similar effect as demonstrated below: I have two menus (http://osiyo-nur.uz/osiyo-nur.uz/test6/), one of which is initially invisible. When I hover over the first menu, the second menu becomes visible with an overlay eff ...

Make the text within the CSS style of ".well" wrap around the width

I am looking to style the width of a .well class to be in proportion with the text inside a simple textbox that it contains. What is the best approach to achieve this sizing using CSS? ...

Changing the class of an element in Svelte: A step-by-step guide

I am working on a svelte application and I want to implement row highlighting when a user clicks on it. Here is an example code snippet that demonstrates this functionality: <div id="A" class="car-even">A</div> <div id=&q ...

Create an interactive table with dynamic content that prevents wrapping using the CSS property

I am trying to create a table with two columns and specific width. The left cell should display a single-line text with auto-ellipsis, while the right cell should have dynamic content that adjusts the width of the cell accordingly, shrinking the left cell& ...

Limiting zero is ineffective when it comes to pop-up issues

Hey there, I'm looking to prevent users from inputting zero and dot in a specific field, which is currently working fine. However, when the field is within a pop-up, the code below doesn't seem to work. <script> $('#name').keyp ...

Incorporating existing CSS styles into a new CSS file

I'm a little confused by the title, so let me clarify with an example. Let's say I have the following CSS code inside a file: #container_1 { width:50%; border:1px solid black; } #container_2 { background-color:red; padding:5px; ...

What could be causing the Bootstrap navbar to not toggle when the button is clicked?

Attempting to create a website featuring a collapsible navbar, but encountering some issues. The button is properly identified with the correct ID assigned. Jquery and bootstrap have been included in the necessary order at the bottom of the body. However, ...

Is there a way to programmatically update a webpage using Javascript?

I have been attempting to set up the code in a way that the page automatically changes using setTimeout. However, I am unable to make it work. setTimeout()(page3, 500); function page3() { changepage3('automatic') } Even though my code is str ...

Modify top position without affecting bottom alignment using CSS

I am currently working on a website that is designed to mimic a printable document. The layout consists of a header, body, and footer, with each element utilizing CSS for margin and height adjustments. The challenge lies in ensuring that the footer is alw ...

Automatically update the border sample once the visitor enters a color code into the input text field

Is it possible to automatically change the sample border when a visitor enters a color code in the input textfield at: Do you have a specific border color in mind? input name="ContentInclude:borderspecs" type="text" maxlength="200" id="ContentInclude_bor ...

Error 404: Django is unable to locate the static/css files

This particular issue appears to be quite widespread, but existing Q&A resources are outdated and do not address my specific problem. Currently, with Django 2.0.2, my basic webpage is failing to render the bootstrap.css file simply because it cannot locat ...

Ensuring that a nested div adjusts responsively within a static parent container

I am working on a project that involves HTML, CSS, and JS code. Here is the structure of my code: HTML: <div id="blockcart-wrapper"> <div class="blockcart cart-preview"> <div class="header"> <a rel="nofollow" href="#"> ...

Enhancing speed on an extensive list without a set height/eliminating the need for virtualization

My webapp includes a feature that showcases exhibitors at an expo. The user can click on "Exhibitors" in the navigation bar to access a page displaying all the exhibitors. Each exhibitor may have different details, some of which may or may not contain data ...

The table contained within a row-spanning cell fails to fully occupy the cell's height across different browsers

Chrome rendering and code issue I'm struggling to understand why the nested table (highlighted in red) is not taking up the full height of the outer table cell (highlighted in green) which spans 8 rows. This used to work fine, but newer browsers are ...