When increasing the zoom level, the footer becomes oddly centered on the page in Bootstrap 4

I've recently started learning Bootstrap with HTML and CSS. Using the bootstrap grid system, I've created three sections like this. Everything looks good on medium screens or larger. However, a problem arises when viewing on smaller screens (or zooming in), causing the content to appear bigger and taller. This results in the footer ending up in the middle of the screen like this.


Here's what I've tried:

  • Setting body height to 100%
  • Clearing both
  • Setting position:absolute; bottom:0
    I suspect the issue stems from the div in the menu. When zoomed in, the content stretches but the footer doesn't adjust accordingly

@import url('https://fonts.googleapis.com/css2?family=Warnes&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Work+Sans:wght@500;700&display=swap');
html,body{
    height: 100%;
    width: 100%;
}
/* Rest of the CSS code... */
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- Importing stylesheet links and font installation -->
</head>

<body>
    <!-- Navbar, Menu, and Footer sections content... -->
</body>

</html>

Answer №1

Here's the solution...

1. Start by wrapping the main content div. This will prevent it from overlapping with the footer.

Simply update this piece of code...

<div class="container w-100 h-100">...</div>

...to look like this.

<div>
    <div class="container w-100 h-100"></div>
</div>

2. Adjust the height of the container. This will place the footer at the bottom of the page.

To achieve this, include the following in your CSS:

.container {
    height: auto !important;
}

3. Eliminate unnecessary elements.

You can remove the footer_main class from your HTML as it serves no purpose.

You can also get rid of the redundant CSS section below:

.footer_container{
    margin-top: auto;
    background-color:#212529;
    color:white;
    width: 100%;
    height: 100%;
    border: none;
}
.footer_main{
    position: relative;
    bottom: 0;
    height:4rem;
}

Review the snippet provided for reference.

[Snippet displaying CSS and HTML code]

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

The input field automatically populates with the username that has been stored in the browser's form

Issue: I have created an input field with the type text, but upon page load, it gets automatically filled with a username saved in the browser's form data for this website's login page. I want it to show up clean when the page loads. <input t ...

Adjusting the size of a React element containing an SVG (d3)

In my simple react app, I have the following component structure: <div id='app'> <Navbar /> <Graph /> <Footer /> </div> The Navbar has a fixed height of 80px. The Footer has a fixed height of 40px. The Graph i ...

Transferring information to the controller and refreshing the interface (Single-page design)

I'm stuck on a personal project and could really use some help. If anyone has any feedback, it would be greatly appreciated. Thanks in advance. In my index.php file, I have a div with the id main-container. Inside this container, there are two separa ...

Implementing Search Filtering in jQuery Tree Tables

Can someone help me troubleshoot my search filter implementation in a treetable using the JQuery library? I've tried following the steps provided, but it's not functioning as expected. Any insights on what might be causing this issue? This is th ...

Guide to positioning text alongside icons with Bootstrap

Struggling to align text next to these icons? Don't worry, we've all been there. Especially with bootstrap - it can be tricky! Can someone please guide me on how to do this? <link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstr ...

The shadow is obscured by a block that has an 'overflow: scroll' property

One block on the left displays the list, while another shows detailed information with a shadow effect. The issue arises when the left block has 'overflow: scroll', causing elements' backgrounds to spill over the shadow. .div-left { flo ...

When the parent div overflows, the child div remains hidden within the boundaries of the parent div

<section class="margin-top-30"> <div class="row" style="position: relative;"> <div class="col-sm-4"> <div class="lightbgblock" style="overflow-x:visible;overflow-y:scroll;"> ...

Expanding a feature that modifies the CSS properties of every input element

Creating a text tracking (letter-spacing) demonstration where range sliders are used to update CSS properties. I'm looking to improve the functionality so that the labels also update dynamically, without repeating output2.textContent = this.value;. An ...

Boost your website's loading time by utilizing the async and defer attributes

Looking to enhance the speed of my webpage, particularly focusing on improving initial page speed. Research suggests that using the async and defer attributes for JavaScript can be beneficial. All JavaScript scripts are currently placed just above the cl ...

Embellishing Bootstrap with a splash of color class

After exploring Bootstrap, I've noticed the limited number of "color classes" available (primary, success, danger etc.). Is there a simple way to add more classes similar to those? For instance, the "primary" class can be used across various elements ...

The functionality of z-index is unreliable when article elements are utilized

Essentially, my goal is to display the <article id="characters"> above the <article id="accordion">. However, despite my efforts, the characters article appears below the accordion article instead of on top or even behind it. Where did I go wr ...

Struggling to properly position my dropdown menu without causing the div content to shift downward

<div id="header"> <a href="#" id="logo"></a> </div> <div id="nav_cont"> <ul id="nav"> <li id="main_btn"><a class="mainlink" href="#">Parent 01</a></li> <li id="communities_btn">< ...

Guide on adding HTML to a specific div element in jQuery by utilizing the keyword "(this)"

I have been working on a script for my PHP page in Wordpress to add titles to images in my photo gallery that open in a lightbox. Here's what I developed: $(".responsive1").bind("click", function() { $(this).("<div class='imgTitle ...

What is the best way to customize the look of the v-calendar component in Vue.js?

I've recently started a project that involves Vue.js, and I needed to create a datepicker for it. After some research, I opted to utilize the v-calendar package. The implementation of the component went smoothly and functioned as expected right out o ...

What is the best way to retrieve ejs data within a form when implementing express?

When a user requests, the following HTML file is displayed in the code below. I also need to access the values of clubname and type inside the app.post() function in my app.js file. <!DOCTYPE html> <html> <head> <title><%= t ...

Using AJAX and PHP to dynamically fill HTML drop-down menus

In order to populate the DropDown controls on my HTML Form dynamically, I have implemented a code that utilizes AJAX to make a call to a .php file. This .php file is responsible for filling the DropDown control with values from a single column. Throughout ...

Internet Explorer 10.0.9200 seems to have a tendency to overlook CSS styles

In my web application, I have implemented a 'tab toolbar' with 3 tabs. When a user clicks on a tab, the page displays different data based on which tab is selected. To visually indicate to the user which tab they have clicked on, I dynamically c ...

Is there a CSS alternative to using <br clear=all> on divs that do not have set heights?

Back in the day, I used to rely on <br clear=all> at the end of a div, without specifying a height value in CSS, just to control its height. These divs would expand and contract based on the content within. Is there a more elegant approach to make ...

Using CSS, create a layout with a small 2x2 box positioned beside a larger 2x2 box

https://i.sstatic.net/nC2PI.png Can a flexible ul li structure be achieved with flexbox? I attempted to set the width of the squares to 25% and make the 1st, 3rd, or 5th one 50% wide using a combination of float:left, clear[left|right], but the last squar ...

Can someone please explain how I can extract and display information from a database in separate text boxes using Angular?

Working with two textboxes named AuthorizeRep1Fname and AuthorizeRep1Lname, I am combining them in typescript before storing them as AuthorizeRep1Name in the database. Refer to the image below for the result. This process is used to register and merge the ...