The Bootstrap Navbar appears hidden beneath other elements on mobile devices

While using bootstrap to style my header contents, I encountered a strange issue. The navbar that appears after clicking on the hamburger menu is displaying behind all the components. Even though I've set the z-index to the maximum value, it still doesn't work. Here's my XHTML:

<header id="header" class="fixed-top">
<div class="container d-flex align-items-center">

  <a href="{% url 'index' %}"><img src="{% static 'assets/img/logo-hi-res.png' %}" alt="" class="ActLogo img-fluid"></a>
  <h1 class="logo me-auto"><a href="{% url 'index' %}"><span>My</span>Website.</a></h1>

  <nav id="navbar" class="navbar order-last order-lg-0">
    <ul>
      <li><a href="{% url 'index' %}" class="{% if nbar == 'index' %}active{% endif %}">Home</a></li>

      <li><a href="{% url 'about' %}" class="{% if nbar == 'about' %}active{% endif %}"><span>About</span></a>

      <li class="dropdown"><a href="{% url '#' %}" class="{% if nbar == 'services' %}active{% endif %}"><span>Services</span><i class="bi bi-chevron-down"></i></a>
        <ul>
          <li><a href="#">Item 1</a></li>
          <li><a href="#">Item 2</a></li>
          <li><a href="#">Item 3</a></li>
          <li><a href="#">Item 4</a></li>
          <li><a href="#">Item 5</a></li>
          <li><a href="#">Item 6</a></li>
        </ul>
      </li>

      <li><a href="#" class="{% if nbar == '#' %}active{% endif %}">Pricing</a></li>
      
      <li><a href="#" class="{% if nbar == '#' %}active{% endif %}">Contact</a></li>
      
      <button class="clientBt btn btn-sm btn-primary mr-2"><a href="#">CLIENT LOGIN</a></button>

    </ul>
    <i class="bi bi-list mobile-nav-toggle"></i>
  </nav>

  <div class="header-social-links d-flex">
    <a href="#" class="twitter" target="_blank"><i class="bu bi-twitter"></i></a>
    <a href="#" class="facebook" target="_blank"><i class="bu bi-facebook"></i></a>
    <a href="#" class="instagram" target="_blank"><i class="bu bi-instagram"></i></a>
    <a href="#" class="linkedin" target="_blank"><i class="bu bi-linkedin"></i></i></a>
  </div>
</div>

As well as the CSS:

#header {
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: grayscale(0) contrast(3) blur(5px);
  transition: all 0.5s;
  z-index: 997;
  padding: 15px 0;
  box-shadow: 0px 2px 15px rgba(0, 0, 0, 0.1);


}


#header .logo {
  font-size: 28px;
  margin: 0;
  padding: 0;
  line-height: 1;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  

}

#header .logo a {
  color: #d40b00;
}

#header .logo a span {
  color: #2C3380;
}

#header .ActLogo {
  width: 60px;
  height:  60px;
  margin-top: -24px;
  margin-bottom: -20px;
  margin-right: 10px;
}

/* Social Links */
.header-social-links {
  margin-left: 20px;
  border-left: 1px solid #c4c4c4;
}

.header-social-links a {
  color: #a0a0a0;
  display: inline-block;
  line-height: 0px;
  transition: 0.3s;
  padding-left: 20px;
}

.header-social-links a i {
  line-height: 0;
}
...

Additionally, includes the JavaScript:

  // Mobile nav toggle
  on('click', '.mobile-nav-toggle', function(e) {
    select('#navbar').classList.toggle('navbar-mobile')
    this.classList.toggle('bi-list')
    this.classList.toggle('bi-x')
  })

  // Mobile nav activate dropdown 
  on('click', '.navbar .dropdown > a', function(e) {
    if (select('#navbar').classList.contains('navbar-mobile')) {
      e.preventDefault()
      this.nextElementSibling.classList.toggle('dropdown-active')
    }
  }, true)

To witness the error firsthand, visit this link, view the mobile version, and attempt to toggle the menu from the hamburger icon.

Answer №1

After some troubleshooting, I discovered that the issue actually lies in a different area than z-index.

  1. The nav element is using an unnecessary overflow-hidden attribute. Remove it.
  2. The ul is missing a specified height. Add min-height: fit-content; to fix this.

Implementing these two adjustments should resolve the problem and function as expected.

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

Using the active class feature in React Router

Hey there! I've been working with react router v6 and using NavLink to move between components. I've been trying to figure out how to add a custom active class in NavLink, but the method I tried isn't working. Here is what I attempted: <N ...

Beginner's Guide: Building your debut JavaScript/TypeScript library on GitHub and npm

I am looking to develop a simple JavaScript/TypeScript library focused on color conversion. Some of the functions and types I aim to export include: export type HEX = string; export type RGB = { r: number; g: number; b: number }; export type RGBA = { r: n ...

What could be causing the "Cannot POST /api/" error to occur when attempting to submit a form?

Having issues with my basic website and struggling to find a solution. As a complete beginner in this field, I am stuck and need some guidance. Accessing http://localhost:3000/class/create works perfectly fine when running the server. However, trying to a ...

contenteditable -- Utilizing AngularJS to create a block element for the title only

When I click on an input field that is editable, I want the background color to change to white within the box. Can someone please assist me with this? Below is my code: HTML <div id="section{{section.index}}"> <h2 class="title" contentedit ...

Show an image in JPEG format using JavaScript within an img tag

Suppose http://example.com/image returns unique image data in response headers and the image itself. Each request to http://example.com/image generates a different image that is not related to the request itself. Besides the image, additional information s ...

Display a loading screen in ExpressJS until the data is fully loaded and ready for use

I am currently utilizing puppeteer to extract data from a job website, and so far everything is running smoothly. app.get('/', async (req, res) => { res.render('index', {text: 'This is the index page'}); }) Up ...

Transforming an image object into a File object using Javascript

My goal is to utilize HTML5 on the client side in order to convert an "image object" into a "File object" for uploading to azure blob storage. I am working with AngularJs and my approach involves: Converting the image to a file Uploading the file to blob ...

Can you spot the real transformation happening?

Is there a built-in way (possibly in one of the frameworks) to determine if a form has been modified from its initial values? The onchange event is not sufficient, as it triggers even if no real change has occurred (such as toggling a checkbox on and off ...

Having trouble with my phonegap app not allowing me to open any

I've just embarked on creating my first phonegap application using an HTML5 mobile website template. After deploying it, I noticed that the external links are not working within the app. Clicking on a link doesn't seem to do anything. To addres ...

working with Selenium in the Chrome web browser

Within a file named e2e.js, the following code was written: const webdriver = require('selenium-webdriver'); const driver = new webdriver.Builder().forBrowser('chrome').build(); driver.get('https://www.google.co.il/'); I h ...

Is there a way to use fetch() to automatically redirect a user after logging in?

I'm currently working on a node.js application using express, and I am in the process of creating a login form for my users. I want to include a Javascript file that utilizes fetch() to send a POST request to my API for user authentication. However, I ...

How can we determine the total number of mandatory fields in an AngularJS form?

Can you explain how to calculate the number of required fields in a form using AngularJS? In my form, there are two required fields (email and select view). I want to display the count on my page - showing 2 if email is filled, 1 if only email is filled, a ...

Checking phone number on a React.js form

I am currently working on a front-end application and need to implement form validation. I am relatively new to ReactJS and learning as I go along in the development process. One of the input fields requires a phone number, which should only accept number ...

How come I am unable to reinitialize my array using setState?

Within my camera module, I am aiming to store photos in a bucket every time three photos are taken. Utilizing state in react, I save the image blobs in an array. Initially, everything functions flawlessly for the first three snapshots; however, subsequentl ...

The earlier polity of the web page no longer retains the JQuery callback method upon refreshing

Whenever I hit the refresh button on Chrome before my Ajax request succeeds, the callback function complete: function(data){ doSomething()} does not execute. function startMockServer() { $.ajax({ url: "/mocks/[[${id}]]/start", type: "P ...

Alter the value of a key within a JSON object at a specific nested level using Node.js or JavaScript

I am attempting to swap out a specific value in the JSON file. Let's say the JSON data provided below: sample.json let sample={ "yuiwedw":{ "id":"yuiwedw", "loc": "ar", "body":{ "data":"we got this", "loc":"ar", "system":{ ...

Show each text field individually in JavaScript

Is it possible to display text fields one by one upon button click? Initially, all text fields are hidden, but when the button is clicked, they should be displayed one after another with their visibility property set to visible? This is what I have attemp ...

Is there a way to eliminate the default arrow on a list input and replace it with a custom arrow solely with html and css?

Is there anyone who can help me figure out how to remove the default arrow in the list input field and replace it with a new arrow icon? <body> <form > <label for="data-list">Choose a browser from this list &l ...

Can you explain the process of a put request in Angular, Express, and Mongoose?

My colleague and I are currently deciphering the inner workings of a code snippet generated by a tutorial. Our main focus is on how the client/server communication flows once line 8 of factory.js is triggered: factory.js app.factory('postFactory&apo ...

Modify the CSS styles of inner elements dynamically

Within my code, I have implemented a SplitPane and included a CSS file that contains the following styling rules: .split-pane > .split-pane-divider { -fx-padding: 0 0 0 1; -fx-background-color:-fx-background; } However, during runtime, I e ...