Ensure that the footer remains at the bottom of the page without being fixed to the bottom

I am currently working on configuring the footer placement on pages of my website that contain the main body content class ".interior-health-main". My goal is to have a sticky footer positioned at the very bottom of these pages in order to eliminate any white space that appears below the footer on large screens. After investing several hours into this task and experimenting with various solutions, I have opted to restrict the sticky footer to only the ".interior-health-main" pages rather than having it apply to the entire website. While I appreciate any assistance in customizing the footer exclusively for these pages, I am not interested in approaches that involve setting the entire body to position: relative as it negatively impacts the layout of my homepage.

For reference, you can observe the issue of white space below the footer on certain pages by visiting the following link: http://codepen.io/aahmed2/full/KgWNYL/

<p class="nav">This is a Navigation Bar</p>
<div class="interior-health-main">
    <div class="container">

        <ol class="breadcrumb">
            <li><a href="/index.asp">Home</a></li>
            <li><a href="/health-resources.asp">Health Resources</a></li>
            <li class="active">Sample Short Page</li>
        </ol>
    <h2>Sample Short Page</h2>



    </div>
</div>

<div class="footer">
  <div class="container">
    <div class="row">
      <div class="col-sm-4">
        <h4>Contact Us</h4>
        <p>414 Hardin Hall<br> 3310 Holdredge St<br> Lincoln, NE 68583<br> (402) 472-7363</p>
        <div class="affiliates">
          <a href="http://www.unl.edu/"><img class="wordmark" src="../_logos/wordmark.svg" alt="University of Nebraska-Lincoln Wordmark"></a>
          <a href="http://extension.unl.edu/"><img class="extension" src="../_logos/n-extension-rev.svg" alt="Nebraska Extension Logo"></a>
        </div>
      </div>

      <div class="col-sm-4">
        <h4>Quick Links</h4>
        <p><a href="#">Human Health</a></p>
        <div class="line"></div>
        <p><a href="/resources/pet-diseases.asp">Pet Diseases</a></p>
        <div class="line"></div>
        <p><a href="/resources/livestock-disease.asp">Livestock Diseases</a></p>
        <div class="line"></div>
        <p><a href="/resources/events.asp">Events</a></p>
        <div class="line"></div>
      </div>

      <div class="col-sm-4">
        <h4>Attention</h4>
        <p>All information on this site is intended for informational use only. Contact your doctor or veterinarian for health concerns.</p><br>
        <h5><a class="partner" href="#">Partners &amp Stakeholders</a></h5>

      </div>
    </div>

    <div class="copyright">
      <div class="col-xs-9">
        <h6>© 2016 Nebraska One Health. <a href="/sitemap.asp">Site Map.</a></h6>
      </div>

      <div class="col-xs-3">
        <a href="#"><img class="social  pull-right" src="../_logos/twitter-logo-button.svg" alt="twitter icon"></a>
        <a href="https://www.facebook.com/nebraskaonehealthresources/"><img class="social  pull-right" src="../_logos/facebook-logo-button.svg" alt="facebook icon"></a>
      </div>
    </div>
  </div>
</div>

Wondering about my css? Here it is:

.nav {
  text-align: center;
  padding: 25px 0;
  background-color: #c1c0be;
  color: #fff;
  position: fixed;
  width: 100%;
  z-index: 2;
}

.interior-health-main {
  padding-top: 80px;
  padding-bottom: 20px;
}

@media (max-width: 479px) {
  .interior-health-main {
    padding-top: 50px;
  }
}

.footer {
  background: #333332;
  border-top: 9px solid #ffffff;
  color: #fff;
  padding-top: 35px;
  padding-bottom: 35px;
}

Answer №1

If you want to make the footer stay at the bottom of the page no matter the content, you can use absolute positioning just like they have done in this example

https://getbootstrap.com/examples/sticky-footer/

.footer {
  position: absolute;
  bottom: 0;
  width: 100%;
  /* Set the fixed height of the footer here */
  height: 60px;
  /* background-color: #f5f5f5; */
}

<footer class="footer">
    <div class="container">
        <p class="text-muted">Place sticky footer content here.</p>
    </div>
</footer>

Did you face any issues or conflicts when trying to implement this? Update your post with your experiences and what you tried.

Answer №2

If you're looking for a solution, please check out this helpful question.

I have implemented a solution from the link provided above into your code.

Make sure to enclose your code within a #holder div.

Include the following CSS:

html,body{
height: 100%
}

#holder{
min-height: 100%;
position:relative;
}

.footer {
background: #333332;
border-top: 9px solid #ffffff;
color: #fff;
padding-top: 35px;
padding-bottom: 35px;
height: 300px; 
width:100%;
position: absolute;
left: 0;
bottom: 0; 
}

.interior-health-main {
padding-top: 80px;
padding-bottom: 300px;    /* height of footer */
}

Take a look at the functional fiddle here: https://jsfiddle.net/DTcHh/25475/

Answer №3

I enclosed your page (excluding the footer) within a .page-wrap div, and made some modifications to your CodePen code by incorporating the following snippet into your CSS

html, body {
  height: 100%;
}
.page-wrap {
  min-height: 100%;
  /* set to match the height of the footer (including margin and border) */
  margin-bottom: -299px ; 
}
.page-wrap:after {
  content: "";
  display: block;
}
.footer, .page-wrap:after {
  /* ensure page-wrap after content matches the height of the footer */
    height: 299px; 
}

View Demo

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

What is the best way to handle mixed parameter types in Spring MVC when sending data from AngularJS?

I am struggling to pass a json object and a string as parameters to my Java controller. Despite my efforts, I keep receiving url = "" in the controller. What could be causing this issue? Is there a solution to successfully passing these parameters? $ ...

jQuery UI has encountered an issue: it seems that #accordion is not a recognized function

While attempting to integrate jQuery UI Accordion into a webpage, I encountered an error message in Firebug upon loading the page: #accordion is not a function The jQuery code I am using is as follows: <script type="text/javascript"> $(document).r ...

Linking two dropdowns in Ember with data binding

I need help with connecting two selectboxes. I want the options in the second one to be determined by what is selected in the first selectbox. I'm new to using Ember and could use some advice on how to approach this problem. I tried using computed pro ...

Ways to retrieve directory information in Next.js hosted on Netlify

Having trouble retrieving a list of directories in Next.js on Netlify. The code works fine on localhost, but once deployed to Netlify, an error is triggered: { "errorType": "Runtime.UnhandledPromiseRejection", "errorMessage": ...

undefined reference to $

I'm currently working on a JavaScript project that involves using key events to display alphabets on the screen. However, I've encountered an error and need some assistance. <!DOCTYPE html> <html lang="en"> <head> <met ...

What is the best way to remove column and row gaps in a Bootstrap grid system?

Despite adjusting padding with the image, div section, and grid gap to 0px in the grid layout, the image still fails to cover the entire cell. I am seeking a solution to eliminate these unwanted paddings that are highlighted in blue. The Bootstrap 5 .g-0 ...

Is there a way to make $animate.removeClass function within a directive without needing to use $eval

I have developed a custom directive that smoothly fades out and fades in the content whenever there is a change in the model. app.controller('myCtrl', function($scope, $interval) { $scope.number = 0; $interval(function() { $scope.number+ ...

Troubleshooting a Non-Responsive React onClick Event in ES6

I am a beginner in React and have been searching on various platforms like StackOverflow and the internet, but I cannot figure out why onClick is not working in my case. When I click the button, absolutely nothing happens. I have tried everything from putt ...

Can AJAX code be applied to elements with identical IDs and checked individually?

I have created multiple instances of the input field <input type="text" class="solution" name="answer" /> along with an image on my view. Users are required to guess what the image depicts. Upon entering their answer in the textbox and clicking or ta ...

Error: React JS is unable to access the property 'path' because it is undefined

Currently, I am encountering an issue while setting the src of my image in React to this.props.file[0].path. The problem arises because this state has not been set yet, resulting in a TypeError: Cannot read property 'path' of undefined. To provid ...

Windows encountering a Node npm error while searching for tools version

Currently, I am encountering an issue while trying to use node on my Windows 8.1 operating system. The problem arises when I attempt to install npm packages using 'npm install package.json'. It all started when I began using Redis, but I'm n ...

When utilizing jQuery, I implemented this code but it does not display anything. I am unsure of the error within the code

When using jQuery, I implemented the following code snippet but it doesn't display anything. What could be causing this issue? // $.ajax({ // URL:"https://dog.ceo/api/breeds/image/random", // method:"GET", // ...

Struggling with loading.jsx file in next js version 13.4.5?

Encountered an issue with loading components in next js 13.4.5 layout.jsx "use client"; import React, { Suspense } from "react"; import { ThemeProvider, createTheme } from "@mui/material/styles"; import CssBaseline from " ...

Steps for styling the header of an Antd Collapse Panel

I'm attempting to modify the text color in the header of an ant panel. Below is the entire ant collapse component code: <Collapse accordion defaultActiveKey={defaultOpenPanel}> <StyledCollapsePanel key="tasksAssignedToMe" header={ ...

Display function not functioning properly following AJAX request

I'm working on a functionality where I want to initially hide a table when the page loads, and then display it with the results when a form is submitted using Ajax. The issue I'm facing is that the code refreshes the page and sets the table back ...

Incapable of utilizing CSS Custom Properties (also known as CSS Variables) in conjunction with SASS @if Conditional Statements

I'm attempting to transfer CSS Custom Properties to a SASS Mixin. I can successfully use the variables directly in the desired styling. However, there seems to be a problem when utilizing a variable within an If statement. Here's an example of t ...

Recalling the layout following the user's computer restart

I am creating a simple online editing tool (similar to Microsoft Outline) for coursework and I would like the outline details to be saved even if the user restarts the system. How can I achieve this? <html> <head> <title>Editor</ ...

Tips for vertically aligning <p> and <div> elements without using the table-cell property

I am trying to align my text vertically in the middle using a ch-grid <div> (the circle color element). Is it possible to achieve this without specifying a display attribute for the <p> element? I plan to hide it by setting display:none initia ...

What is the best way to reindex dynamically added rows in jQuery?

I've been searching everywhere, but I can't seem to find the solution to my problem. I have a table where rows are dynamically added based on an index. So, when I click on a link in row 5, I want to add a new row at index 6. The issue arises when ...

Explore flat data querying using Firebase and AngularFire

I am working with data stored in firebase, utilizing a flat structure with key-value pairs to establish a many-to-many relationship between events and users (see figure 1). While it's straightforward to look up events associated with a user using pure ...