Troubleshooting the Sticky Footer Problem in Bootstrap 4

Recently, I've delved into the world of web development with bootstrap and have come across an issue with my footer...

Currently, my desktop version footer looks like this:

https://i.sstatic.net/qMuSJ.jpg

All the footer elements are displayed in line perfectly.

However, when I switch to the mobile design, the footer elements stack on top of each other rather than remaining in line:

https://i.sstatic.net/z5EW4.jpg

I attempted to rectify this by using media queries and CSS, adding a display: inline-block to the HTML list, but unfortunately, it didn't work. I'm unsure of what I should do to keep it displaying correctly.

Here is the CodePen link for the footer: https://codepen.io/rgmislife/pen/poJJeyV

.footer-page {
  background-color: #d2d7e8;
  right: 0;
  bottom: 0;
  left: 0;
  position:relative;**
  width: 100%;
  height: auto;
}

@media screen and (min-width: 320px) and (max-width: 1024px) {
  .footer-page {
    position: relative;
  }
}

@media screen and (min-width: 768px) and (max-width: 1024px) {
  .footer-page {
    position: absolute;
  }
}
.navbar-brand {
  font-family: 'Raleway', regular;
  color: white;
  font-size: 15px;
  letter-spacing: 1px;
}

.icon {
  font-size: 0.4rem;
}

.nav-link {
  font-family: 'Raleway', Semi-Bold;
  letter-spacing: 1px;
  color: #3a5199;
  font-size: 15px;
  letter-spacing: 1px;
}
<link href="//use.fontawesome.com/releases/v5.0.7/css/all.css" rel="stylesheet"/>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" rel="stylesheet"/>
<footer>
 <div class="footer-page">
   <nav class="navbar navbar-fixed-bottom navbar-expand-md bg-faded justify-content-center">
     <a href="index.html" class="navbar-brand d-flex w-50 mr-auto">Brand</a>
      <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#collapsingNavbar3">
         <span class="navbar-toggler-icon"></span>
      </button>
      <div class="navbar-collapse collapse w-100" id="collapsingNavbar3">
          <ul class="navbar-nav">
            <li class="nav-item active">
               <a class="nav-link" href="#"><i class="fab fa-linkedin fa-2x"></i></a>
             </li>
           <li class="nav-item d-inline-block">
              <a class="nav-link" href="nous-contacter.php"><i class="fas fa-envelope fa-2x"></i></a>
            </li>
        </ul>
        <ul class="nav navbar-nav ml-auto w-100 justify-content-end">
…
</ul>
       </div>
     </nav>
   </div>
</footer>

This is the CSS code I tried:

.nav li {display: inline-block;}

If anybody has any suggestions or solutions, please feel free to share. Thanks!

Answer №1

Is this the solution you've been seeking?

@media screen and (max-width:768px){
  .navbar-nav{
    flex-direction: row;
  }
  .navbar-nav .nav-item{
    margin: 0 10px;
  }
}

On mobile devices, your elements will stack due to text length and varying screen sizes.

Answer №2

Your links appear stacked due to not fitting into the container. Without altering your HTML structure, there isn't much you can do. I recommend reorganizing the layout for a cleaner look.

To quickly address this (assuming you are using Bootstrap):

  • Remove the w-50 class from the navbar-brand link as it's causing the stacking issue.
  • If you want the icons centered within the navbar-collapse with the links, remove the ml-auto w-100 classes from the ul containing the links. Instead, add mx-auto to the ul containing the icons, positioning them between the brand and links.

View the full-page snippet for better context.

.footer-page {
  background-color: #d2d7e8;
  right: 0;
  bottom: 0;
  left: 0;
  /**position:absolute;*/
  position: relative;
  width: 100%;
  height: auto;
}

@media screen and (min-width: 320px) and (max-width: 1024px) {
  .footer-page {
    position: relative;
  }
}

@media screen and (min-width: 768px) and (max-width: 1024px) {
  .footer-page {
    position: absolute;
  }
}

.navbar-brand {
  font-family: 'Raleway', regular;
  color: white;
  font-size: 15px;
  letter-spacing: 1px;
}

.icon {
  font-size: 0.4rem;
}

.nav-link {
  font-family: 'Raleway', Semi-Bold;
  letter-spacing: 1px;
  color: #3a5199;
  font-size: 15px;
  letter-spacing: 1px;
}
<link href="//use.fontawesome.com/releases/v5.0.7/css/all.css" rel="stylesheet"/>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" rel="stylesheet"/>
<footer>
  <div class="footer-page">
    <nav class="navbar navbar-fixed-bottom navbar-expand-md bg-faded justify-content-center">
      <a href="index.html" class="navbar-brand d-flex mr-auto">Brand</a>
      <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#collapsingNavbar3">
        <span class="navbar-toggler-icon"></span>
      </button>
      <div class="navbar-collapse collapse w-100" id="collapsingNavbar3">
        <ul class="navbar-nav mx-auto">
          <li class="nav-item active">
            <a class="nav-link" href="#"><i class="fab fa-linkedin fa-2x"></i></a>
          </li>
          <li class="nav-item d-inline-block">
            <a class="nav-link" href="nous-contacter.php"><i class="fas fa-envelope fa-2x"></i></a>
          </li>
        </ul>
        <ul class="nav navbar-nav justify-content-end">
          <li class="nav-item">
            <a class="nav-link" href="nous-contacter.php">Nous contacter</a>
          </li>
          <li class="nav-item">
            <a class="nav-link" href="mentions.html">Mentions Légales</a>
          </li>
          <li class="nav-item">
            <a class="nav-link" href="CGV.html">CGV</a>
          </li>
          <li class="nav-item">
            <a class="nav-link" href="presse.html">Presse</a>
          </li>
          <li class="nav-item">
            <a class="nav-link" href="evenements.html">Evénements</a>
          </li>
        </ul>
      </div>
    </nav>
  </div>
</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

Animating the change of background image position in jQuery

Struggling to change the background image position in jQuery animation? Need some assistance to troubleshoot it? Here is the code you are working with: CSS #pnav a{ background:url(http://www.us-bingo.com/images/Tickets/Solid-Color-Tyvek-Wrist-Ticket ...

The primary text is getting truncated when an ion-note is placed inside an ion-list

I'm currently working with Ionic 3 and attempting to create a list of events where the event name appears on the left and the event note (start time) appears on the right using an ion-note. Below is the code snippet: <ion-list *ngIf="events.len ...

Having trouble getting IcoMoon icons to display properly in Internet Explorer 8?

While using IcoMoon icons on my website, I have noticed that they function perfectly in all modern browsers except for Internet Explorer 7, where they do not display at all. In Internet Explorer 8, the icons show up as small boxes instead. The CSS code I a ...

Creating a Stylish Navigation Bar with Bootstrap4 - Organizing Elements for Just the Right Look

I am trying to organize my content within a navbar into 3 different 'columns'. I want a logo on the left, some navigation items in the center, and the last element ("Get The App") on the right, but I am facing some challenges. Below is my code s ...

How to position a textarea alongside a checkbox using CSS with Bootstrap

I'm having an issue aligning a text area next to a checkbox in my Bootstrap HTML. Here's the code snippet: <div class="form-group row"> <div class="col-12 form-check"> <label class="col-3 col-form-label" for="check15"& ...

How to toggle visibility of previous and next elements in a Laravel carousel

Just starting out with Laravel and Bootstrap. I'm attempting to showcase database data in a carousel format. Within the database, I've populated a few rows with text which I'd like to display on individual slides. My goal is for one row/sl ...

What is the best way to ensure that a navbar dropdown appears above all other elements on

I'm having trouble creating a navbar dropdown with material design. The dropdown is working fine, but the issue I'm facing is that other elements are floating above it. https://i.stack.imgur.com/aJ0BH.png What I want is for the dropdown to floa ...

Ways to toggle the visibility of an element based on the condition of two other elements

I'm facing a challenging UI use-case that I just can't crack. I have 2 non-nested divs that are causing me trouble (not nesting is crucial here as it would have made things much simpler). Here is the structure of the divs: <div class="a"> ...

Issue resolved: Mysterious fix found for background images not displaying in NextJS React components

I am having trouble displaying a background image on an element in NextJs using Typescript and Tailwind. I do not believe it is a TypeScript issue since I am not receiving any errors or IntelliSense warnings. Below is the code I am working with: var classn ...

Linking a script to a button in ASP .NET MVC Razor View

I'm struggling to get a button to invoke a script. Here's the button and script: <script> function SubmitClick () { var pid = $(this).data('personid'); var sid = $(this).data('surveyid'); v ...

React component with element style declared in module.css file and conditional state

I'm in the process of developing a mobile dropdown feature for a React web application. I am looking for guidance on the proper syntax to use when incorporating multiple classes into a React element. My goal is to apply styles from an imported module ...

The collapsible menu does not toggle when I tap on the icon

I am currently troubleshooting an issue with this link "https://sampledemos.online/training/index.html" where the toggle feature is not functioning properly. Below are the codes I have written: <aside id="layout-menu" class="layout-menu m ...

Text that fades in and out based on scrolling past a specific point

There's a text containing <p> and <h1>. The text finishes with one <h1>. I'm looking to speed up the Y translation of the <p> twice when I reach the bottom of the document (where the last h1 is located in the middle of th ...

The text alignment in Internet Explorer is off

After testing this website on both Firefox and Chrome, the alignment in the "Releases" section appears to be correct: However, when viewed in Internet Explorer, some of the text seems to be aligned in the center for unknown reasons. I have been struggling ...

The alignment of the floating left element is creating conflicts with the styling of other div

As I embark on a design project, I find myself juggling three divs for distinct products, alongside a payment method image div and a copyright div. The product divs are aligned to the left within their specific wrapper, ensuring they center and display sea ...

What is the best way to apply filtering to my data source with checkboxes in Angular Material?

Struggling to apply datatable filtering by simply checking checkboxes. Single checkbox works fine, but handling multiple selections becomes a challenge. The lack of clarity in the Angular Material documentation on effective filtering with numerous element ...

Loading content dynamically into a div from an external or internal source can greatly enhance user experience on a website. By

As I work on my website, I am incorporating a div structure as shown below: <div class="container"> <div class="one-third column"> <a id="tab1" href="inc/tab1.html"><h2>tab1</h2></a> </div> & ...

Experiencing issues with a malfunctioning Chrome extension? The CaptureVisibleTab feature seems to be failing when using

Whenever I try to use the captureVisibleTab function on a page where I have a div with preserve3d in CSS3, all I see is a blank page. How can I solve this issue? Here is my simple code for capturing the browser screen: chrome.browserAction.onClicked.addL ...

The CSS selector functions as expected when used in a web browser, however, it

While conducting test automation using Selenium, I typically rely on css selectors to find elements. However, I recently came across a peculiar issue. I observed that in certain cases, the css selector works perfectly when tested in the browser console. Fo ...

Why isn't Freichat displaying the name of the user who logged in?

After creating my own small social networking site, I decided to add a chat script called freichat. However, I am facing an issue where when a user logs in, their name appears as "Guest102" instead of their actual name. I am quite confused by this problem ...