Ensure the footer is positioned at the bottom of the page using Bootstrap

I am having trouble with placing my footer at the end of the page when there is only a little text. I added h-100 to the container to try and fix it.

<div class="container h-100" style="margin:40px;"> <!-- wrapper for all containers -->

However, when there is a lot of data on the page, the footer ends up overlapping with the data. How can I resolve this issue? An example is shown in the image below (black line represents the footer). https://i.sstatic.net/lOb0K.png

This is my code:

{% extends 'vacancy_list/base.html' %}

{% block content %}

<div class="container h-100" style="margin:40px;"> <!-- wrapper for all containers -->
    {% for vacancy in vacancies %}
    <div class="card">
        <div class="card-header">
            <div class="row">
                <div class="col-md-8">
                    <h1><a href="#">{{vacancy.title}}</a></h1>
                </div>
                <div class="col-md-4 text-right">
                    <p> 40000 </p>
                </div>
            </div>
        </div>
        <div class="card-body" style="white-space:normal">
            <p> Описание вакансии: Компания Sixhands, занимающаяся разработкой мобильных приложений и веб-порталов в Санкт-Петербурге, ищет Backend-разработчика для создания серверной части мобильных приложений.
        </div>


    </div>
    {% endfor %}
</div> <!-- wrapper end -->

{% endblock %}

Answer №1

This solution was a game-changer for me

<head>
    <link rel="stylesheet" href="bootstrap/css/bootstrap.min.css">
    <script src="bootstrap/js/bootstrap.min.js"></script>
    <style>
        html,
    body {
      height: 100%;
    }

    #page-content {
      flex: 1 0 auto;
    }

    #sticky-footer {
      flex-shrink: none;
    }


    body {
      background: #007bff;
      background: linear-gradient(to right, #0062E6, #33AEFF);
    }
    </style>
</head>

<body class="d-flex flex-column">
  <div id="page-content">
    <div class="container text-center">
      <p> INSERT YOUR TEXT HERE
    </div>
  </div>
  <footer id="sticky-footer" class="py-4 bg-dark text-white-50">
    <div class="container text-center">
      <small>Copyright &copy; Your Website</small>
    </div>
  </footer>
</body>

Answer №2

If you find yourself in need of a sticky footer, one effective method is to convert the entire page into a Flexbox layout:

html,
body {
  height: 100%;
  margin: 0;
}

header {
  background: yellow;
}

main {
  background: pink;
}

footer {
  background: lightblue;
}

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

main {
  flex: 1;
}
<header>HEADER</header>
<main>MAIN</main>
<footer>FOOTER</footer>

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 customize bootstrap styles?

Currently, I am attempting to modify basic CSS attributes within the default theme that is included with a new ASP.NET MVC 5 application in Visual Studio 2013. Specifically, my goal is to change the background color of the navigation menu. With the help o ...

Troubleshooting CSS keyframe animation issues in IE and Edge

I have created an animation that works perfectly in all browsers except for IE and Edge. You can view the page here. .progress-container { position: relative; } .background-progress-bar, .progress-bar { width: 100%; height: 10px; top: 0px; left ...

Creating a Set of Buttons in HTML

Need some assistance with grouped buttons. Let's consider a scenario where there are 5 buttons on an HTML page. When the 3rd button is clicked, buttons from 0 to 3 should change color and the function should return 3. Similarly, when the 5th button is ...

What is the best way to conceal the bottom portion of an image?

My image in the header overlaps with the next section's features (image-phone). https://i.sstatic.net/4g0SO.jpg I've tried changing the position and z-index types. If I crop the image, it's not ideal and difficult to fix ;) How can I stru ...

javascriptif the number is a whole number and evenly divisible

I am currently developing a script that tracks the distance traveled by some dogs in meters. It is basically just a gif running in a loop. What I want to achieve now is to display an image every 50 meters for a duration of 3 seconds. Here's my attempt ...

What is the best way to upload this HTML file to create my own visual representation?

Feeling a bit unsure about which way to go for this problem, I don't have many options at the moment. Lately, I've been diving into Deep Learning and I'm interested in experimenting with Stanford's CS231N's Convolutional Neural Ne ...

Placing an image in context with the background image

Looking for guidance on CSS styling. I have successfully set up a responsive background image on my page and now want to add a circular logo positioned at the bottom center of it. However, I am facing an issue where the logo's position changes when th ...

Add HTML content to a specific div according to the option selected in a drop-down menu

I am currently working on a project where I need a button to insert HTML content into a div based on the value selected in a select box. However, the functionality is not working as intended. Upon clicking the button, nothing happens. I am unsure of what t ...

"Learn the process of customizing the border color of a drop-down menu using

Is there a way to add validation to a drop-down menu so that the border color turns red if an option is not selected? $("#MainContent_ddlSuppliers option:selected'").css("border", "1px solid #F78181"); ...

Utilizing Python to dynamically create unique tags from deeply nested dictionaries through recursion

As part of my project, I am developing a unique dynamic template tool that can seamlessly integrate with any templating framework such as pugs and jinja. The goal is to create a demo that resembles the following structure: view! { div { p { ...

Struggling with displaying Vuetify list items correctly?

I am implementing vuetify to display the list items in the following structure: Interests btn1 btn2 btn3 btn4 Not Interests btn1 btn2 btn3 btn4 However, the titles "Interests" and "Not Interests" are not showing up correctly. <v-layout row wrap&g ...

Retrieving the selected value from a dropdown menu without having to click on a

I'm facing an issue with 2 dropdown menus outside of an HTML table that is generated by PHP code. There's a submit button within this table, and here's how it's set up: <!doctype html> Select Year: ...

If the text is too wide for the parent div width, wrap it in a child div

<div class='jfmfs-friend' id='123'> <input type='checkbox'/> <img src='id.jpg'/> <div class='friend-name'>Himanshu Yadav</div> </div> I am looking to modify the st ...

What could be the reason for the image not aligning to the middle with vertical-align?

I'm facing an issue with the alignment of images on my website. The images are currently displayed from the top, but I would like them to be aligned in the middle vertically. However, using the 'vertical-align: middle' property on the images ...

Can an action be activated when the mouse comes to a halt?

Currently, I am having trouble triggering an event when a user stops moving their mouse over a div element. The current event is set up to show and follow another element along with the mouse movement, but I want it to only display when the mouse stops mov ...

Firebase authentication encountered an error due to a network request failure

Utilizing firebase Hosting to host my website, I am encountering a persistent error when attempting to login using email/password. This is the JavaScript code that I am using: window.onload = () => initApp(); //Initialize screen function initApp(){ ...

Storing the days of the week along with the respective times in a database: a

I am new to building an app on Laravel and I'm looking to add a feature where users can input a specific weekday and time to be stored in the database. I'm not sure what datatype to choose or how to create the HTML form for this. For my universi ...

What is the reason behind the malfunction of the float?

Having an issue with the "1" form not extending to 100% width next to the "Tickets". Here is a visual representation of the problem: View how it currently looks here. html: <section id="main_content"> <div class="left inner"> ...

Troubleshooting problem with AngularJS and jQuery plugin when using links with # navigation

I have integrated a specific jquery plugin into my angularjs single page application. The primary block can be found in the following menu: http://localhost:81/website/#/portfolio This menu contains the following code block: <li> <a href=" ...

JavaScript: How can I remove it when I click anywhere on the webpage with onClick?

A challenge I'm facing involves creating a form with an input field that changes its border color when clicked. My goal is for the border to return to its original color when clicking anywhere else on the page. -HTML <form action=""> ...