Ensuring Footer Stays at Bottom of Page with the Power of Server-Side Includes

I am currently working on a website with multiple pages. To streamline the process, I have opted to use server-side includes for the header and site contents bar across all pages. However, I am facing difficulty in getting the footer positioned at the bottom of each page.

Despite trying various solutions from Stack Overflow, it seems that the height of the help contents (utilizing JQuery accordion) is causing trouble. I suspect there might be an issue with the CSS formatting or something missing from the HTML code.

I wonder if there could be a more efficient way to achieve the inclusion of headers and footers without duplicating the HTML code on every page. The link to a sample page containing a footer can be accessed here.

Below is a snippet of the HTML code used in the mentioned page:

<body>

<div class="page-content">

<!--#include file="../../../_includes/header.shtml"-->

<div class="container">
    <h2 class="container-header">About Widget</h2>
    <div>
        <p class="container-text">The About widget is located in the upper right-hand corner of the application, within the header, as shown below.</p>
    </div>
    <div class="widget-header-figure-container">
        <figure>
            <img class="widget-header-figure-image" src="images/about.jpg" alt="AboutWidget">
            <figcaption class="figure-caption">About widget highlighted in red</figcaption>
        </figure>
    </div>
    <div>
        <p class="container-text">The About widget provides a synopsis of the application as well as the layers included within the map. Additional links that may be of interest are also provided.</p>
        <p class="container-text">Contact information for the <a class="link" href="http://linncounty.org/418/GIS-Division" target="_blank">GIS Division</a> and <a class="link" href="http://linncounty.org/292/Real-Estate-Services" target="_blank">Real Estate Division</a> can be found. The Web AppBuilder Developer Edition version and application build date can be found at the bottom.</p>
    </div>

</div>

<footer>
<!--#include file="../../../_includes/footer.shtml"-->
</footer>

</div>

</body>

Here is the sample CSS corresponding to the above code:

html {
    font-size: 62.5%;
    height: 100%; 
}

body {
    background-color: #d2d2d2;
    font-family: 'Cuprum';
    height: 100%;
}

.page-content {
    min-height: 100%;
    position: relative;
}

#footer-container {
    width: 100%;
    height: 150px;
    background-color: #797986;
    bottom: 0;
    position: absolute;
    text-align: center;
}

Answer №1

To optimize the layout, I would eliminate the height property from both body and html. Instead, I suggest applying

min-height: 100vh; overflow: auto; padding-bottom: 150px; box-sizing: border-box
to the .page-content class to define its height. Additionally, it's essential to clear any floated elements in the navigation bar, add padding at the bottom to accommodate the footer, while ensuring the total height does not exceed 100vh + 150px. Furthermore, I updated the CSS selector for the footer element by removing the id reference.

html {
  font-size: 62.5%;
}

body {
  background-color: #d2d2d2;
  font-family: 'Cuprum';
  margin: 0;
}

.page-content {
  min-height: 100vh;
  position: relative;
  overflow: auto;
  padding-bottom: 150px;
  box-sizing: border-box;
}

footer {
  width: 100%;
  height: 150px;
  background-color: #797986;
  bottom: 0;
  position: absolute;
  text-align: center;
}
<body>

<div class="page-content">

<!--#include file="../../../_includes/header.shtml"-->

<div class="container">
    <h2 class="container-header">About Widget</h2>
    <div>
        <p class="container-text">The About widget is located in the upper right-hand corner of the application, within the header, as shown below.</p>
    </div>
    <div class="widget-header-figure-container">
        <figure>
            <img class="widget-header-figure-image" src="images/about.jpg" alt="AboutWidget">
            <figcaption class="figure-caption">About widget highlighted in red</figcaption>
        </figure>
    </div>
    <div>
        <p class="container-text">The About widget provides a synopsis of the application as well as the layers included within the map.  Additional links that may be of interest are also provided.</p>
        <p class="container-text">Contact information for the <a class="link" href="http://linncounty.org/418/GIS-Division" target="_blank">GIS Division</a> and <a class="link" href="http://linncounty.org/292/Real-Estate-Services" target="_blank">Real Estate Division</a> can be found.  The Web AppBuilder Developer Edition version and application build date can be found at the bottom.</p>
    </div>

</div>

<footer>
  footer
</footer>

</div>

</body>

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

Jquery issue: Property or method is not supported by this object

Implementing a tree structure on my JSP Page using jQuery has been quite challenging. The tree structure necessitates the import of several jQuery files. However, upon running the JSP page, I encountered an error with the message "Object doesn't suppo ...

The ul media queries have malfunctioned

In the .gallery section, there are 12 li elements that contain images. Originally, I used media queries to adjust the number of columns in the grid to 6, 4, 3, and 2 based on the browser width. However, when I tried to create a size ratio of 2:1 for all ...

Utilizing the power of jQuery's `.clone` method to create a new window with fully

I am currently working on a project where I need to duplicate a page while maintaining its functionality, and then display it in a new window. My goal is to only clone a specific portion of the page, but for now I am focusing on replicating the entire page ...

Implementing a function when a grid's action column is clicked

I am facing an issue with a yii grid that includes an action column with custom buttons. I want to call a function when one of the buttons is clicked, but I keep getting an error. Here is the code snippet: [ 'class' => 'kartik&b ...

Identifying duplicated video duration data associated with videoIds in asynchronous calls using Youtube API v3

I've encountered an issue with the asynchronous methods that retrieve and display all vidDuration values followed by the corresponding viewCount values for each videoId. The problem arises when the vidDuration value repeats only the last received one ...

Increasing the range of numbers with Jquery's span functionality

Recently, I've been experimenting with jQuery in my WordPress theme project. I wanted to spice things up a bit by adding some cool features. After receiving some helpful JS code from a great website, I used it to wrap numbers in a specific div with a ...

Custom error messages in jQuery validation

I'm having trouble implementing jQuery validation with the data-val-lookup attribute on my input fields: Below is the code snippet I'm using to set up the validation rule: $(function () { $.validator.addMethod('lookup', function ( ...

Populate an array with a series of dates, verify their accuracy, and determine the highest value within

Below are some input fields: <input type="text" name="date_1" class="dataList" value="2009-12-30" /> <input type="text" name="date_2" class="dataList" value="2007-06-12" /> <input type="text" name="date_3" class="dataList" value="2009-10-23 ...

Unable to retrieve JSON data from php script, but able to successfully retrieve it from file.json

This is the function of my PHP testing script: $json = array ( "age" => 5, "name" => "Lee", ); $json = json_encode($json); echo $json; The JSON data is successfully printed out. When I save its content in a file named file.json and read ...

Capture information from an HTML5 form and securely store it in a MySQL database

I have a simple web form that includes a "date" type input field. I want to retrieve the date entered by the user and store it in my MySQL database, which has a DATE type column. I am looking for some PHP/JS magic to facilitate the communication between t ...

Placing a button at the bottom of a bootstrap well

Hey there, I'm facing an issue with the button positioning. I really need the button to be placed at the bottom of the well, but for some reason, it keeps showing up next to the image instead. This is what's happening: the button is ending up be ...

Are there any tools available for converting Arabic HTML to PDF for free?

Converting an HTML page in Arabic to a PDF seems to be a challenge with itextsharp. Below is an example of HTML content with Arabic text: <div> <table border="1" width="500px"> <tr> <td colspan="2"> ...

Making alterations to the HTML code of a Tumblr theme in order to eliminate specific

Here is my custom Tumblr domain URL: http://intchauhan.com/ I would like to eliminate the "Follow intchauhan" and "tumblr." buttons located on the right side. Below is the HTML of the theme: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional// ...

Is there a way to create an internal link to another HTML templating engine page within Express.js?

I am currently facing an issue with two Pug files, index.pug and search.pug, stored in a /views folder. In my index.pug file, I have the following line of code: a(href="/search.pug") Search In my JavaScript file, I have specified the view engine as P ...

Is it possible to achieve the same functionality as :first-child by employing :nth-of-type without a selector?

Currently tackling a console warning related to MUI5/emotion (I believe) I have noticed that the pseudo class ":first-child" might pose potential risks during server-side rendering. It may be worth considering replacing it with ":first-of-type". I wonder ...

Issues with the bootstrap 4 modal update

I am currently working on an app in Spring Boot with JSP for the frontend, and I have encountered a specific issue: In my application, there is a table with multiple rows where I can click a button to update each row as needed. When I click on one row and ...

JS backbone require global models in js

I am looking to implement a UserSession model that will handle loading and saving session IDs into cookies using the jQuery cookie plugin. Below is the code for my UserSession model module: define(['jQuery', 'Underscore', 'Backbo ...

Pagination for comments using ajax in Wordpress

I am currently fetching my Wordpress comments from the database through a custom query and displaying them accordingly. I am utilizing the paginate_links() function in Wordpress to paginate the comments. Below is the code snippet: <div class="commentsW ...

The largest contentful paint is anticipating an unidentified event

My website is encountering issues with Google Pagespeed and I'm unsure of the cause. The primary bottleneck appears to be the LCP time, which Google reports as taking between 7 and 11 seconds during each test. Upon analyzing the waterfall chart, it ...

Cease adding to the list once the condition is no longer valid

I am currently working on a project that requires me to clone span.response11, attach it to #parent, and then insert a new div into the cloned span.response11. I have successfully completed the cloning process, but I am facing an issue where my IF statemen ...