Why is the text getting covered by the drop down menu?

I am currently working with bootstrap classes and I am facing an issue where the drop down menu is overlapping with the text. You can see the problem in the screenshot here: enter image description here

  <div class="collapse navbar-collapse" id="navbarSupportedContent">
            <ul id="nav-list" class="nav navbar-nav navbar-right d-block d-sm-none row">
                <li class="li-Menu text-center">Chiken</li ><hr">
                <li class="li-Menu text-center">Beef</li><hr">
                <li class="li-Menu text-center">Sushi</li>
            </ul>
          </div>

After checking, I noticed there was a me-auto class that I removed. I have searched for a solution but so far, I have not found one.

Answer №1

Indeed, it is a simple fix

To correct this issue, add the provided CSS code to your stylesheet

#navbarSupportedContent {z-index:99;}

Alternatively, you can use the class name instead

.collapse {z-index:99;}

By doing this, the dropdown will take priority and appear above other elements when opened

Update: You may also try the following:

<div class="collapse navbar-collapse" id="navbarSupportedContent" tabindex=”0” style=”z-index:10;”>

Answer №2

To resolve this issue, you can easily adjust the z-index of your navbar dropdown so that it appears above other elements. Simply add the following CSS: .collapse { z-index: 1000; }

Additionally, to ensure that nothing appears below the dropdown, you can set its background-color to white using this CSS:

.collapse { background-color: white }

If you need the dropdown to push elements below it downwards, you can use the following CSS: .collapse { display: block }. However, if the elements below are absolutely positioned, the method may vary.

Edit: @Marcus Petersen requested the code for implementing these changes, so here it is.

CODE:

var opened = false;
function openclose() {
    if (opened == true) {
        document.getElementById("openclose").innerHTML = "[Click] Open";
        document.getElementById("collapse").style.height = "0%";
        opened = false;
    } else {
        document.getElementById("openclose").innerHTML = "[Click] Close";
        document.getElementById("collapse").style.height = "250px";
        opened = true;
    }
}
.collapseable {
    width: 100%;
}
.menu {
    width: 100%;
}
.collapseable p {
    text-align: center;
}
.collapseable {
    position: absolute; /* Change to block to move the stuff below it down */
    height: 0%;
    overflow-y: clip;
    background-color: white;
    z-index: 1000;
    transition: height 0.5s linear;
}
<html>
  <nav>
      <button class="menu" onclick="openclose()">
          <span>Menu</span>
          <br>
          <span id="openclose">[Click] Open</span>
      </button>
      <div class="collapseable" id="collapse">
          <p>Menu Item 1</p>
          <hr>
          <p>Menu Item 2</p>
          <hr>
          <p>Menu Item 3</p>
      </div>
  </nav>
  <h1>Lorem Ipsum</h1>
  <p>Lorem ipsum dolor sit amet (and then more lorem)</p>
</html>

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

Issue with WordPress navigation menu bug

On my website, I have implemented WP nav menu and it seems to be functioning correctly. However, I am facing an issue with the sub link under the home link. The screenshot shows the problem clearly. In the provided image, the "support our work" sub link a ...

Issue with triggering function within Material UI Tabs

The issue I encountered cannot be replicated, but I attempted to address it. Within a Material UI element, there is a child element that I inserted - an X icon located in the corner. The parent element is the surrounding box. There are two main problems: ...

How can I distinguish the search results from the while loop section at the bottom of the page?

One issue here is the footer's margin position being influenced by the results of the while loop. To see the problem more clearly, visit this link: Below is the code snippet: <div id="print_output1"> <?php $co ...

Troubleshooting: Unable to load template file content in AngularJS ng-view

Setting up a demo angular app has been quite the challenge for me. Despite my efforts, the content from my partial file (partials/test.html) is not loading into the layout file as expected. Below is a snippet of my index.html: <!DOCTYPE html> <ht ...

Having issues with Django not recognizing multiple identical GET parameter names

A Django form is being used for filtering data via a GET form: from reservations.models import Reservation, ServiceType from django import forms PAYMENT_OPTIONS = ( ('CASH', 'Cash'), ('ROOM', 'Charge to room&apo ...

Have the validation state classes (such as .has-error) been removed from Bootstrap 5?

I've noticed that the validation state classes (.has-success, .has-warning, etc) seem to have been removed in bootstrap 5 as they are not working anymore and I can't find them in the bootstrap.css file. Before, I could easily use these classes w ...

Add the application's logo image to the Ionic header along with a side menu

When attempting to place the app logo image in the center or left of the Ionic header with vertical alignment, it seems to shift to the top instead. The code I am currently using to display the logo is causing some issues: <ion-view view-title="<im ...

Styling the background of a container in CSS using Bootstrap

Currently, I am utilizing bootstrap and trying to find an elegant solution for adding a background to my container. Specifically, I am working with the bootstrap class container, as opposed to container-fluid. The official Bootstrap documentation advises ...

Creating an Android application that integrates HTML styling efficiently

I currently have a social networking site with a mobile web version, and my goal is to package that view into an Android app and potentially enhance it with a custom splash screen. Essentially creating a branded browser window. If you have any tips or adv ...

Creating a fading effect on an image in relation to another dynamic image

I am currently facing an issue in my code where I am trying to make one image fade in next to another, regardless of the position of the movable image on the screen. The movable image can be controlled using arrow keys, and when I move it across the screen ...

Attaching a CSS file to a personalized WordPress widget

After much searching and struggling due to language barriers or lack of PHP knowledge, I couldn't figure out how to achieve this: public function widget( $args, $instance ) { ?> <div style="padding: 0 0 14% 0"> <div class="m ...

Guide to center-aligning ElementUI transfer components

Has anyone successfully incorporated ElementUI's transfer feature inside a card element and centered it? https://jsfiddle.net/ca1wmjLx/ Any suggestions on how to achieve this? HTML <script src="//unpkg.com/vue/dist/vue.js"></ ...

Maintain parent hover effect while child is being hovered over

After exploring various solutions to fix an issue, I've hit a roadblock. Adding CSS and jQuery code seemed promising at first, but upon refreshing the browser, a new problem emerged. The parent element retained its hover state background color, but th ...

Adjust the color of the IconButton

I am trying to customize the color of an IconButton by setting it to red <IconButton variant='contained'> <StarBorderRoundedIcon color='red' /> </IconButton> However, when I try this, the red color ...

Having trouble accessing the iframe element in an Angular controller through a directive

My webpage contains an iframe with a frequently changing ng-src attribute. I need to execute a function in my controller each time the iframe's src changes, but only after the iframe is fully loaded. Additionally, I require the iframe DOM element to b ...

pass user identification by using a link using php and MySQL

In my table of items, there is an option for users to delete or restore each item, using a special PHP file called 'delete.php'. print "<td>"; if ($row['deleted'] == 'y') { print "<a href='delete.php?id=2'& ...

The Americanpurpose1 font family features playful smiley faces when special characters such as parentheses and hashtags are used

I have utilized the font family americanpurpose1 for my current project, however, I am encountering issues where special characters such as (), #, etc. are displaying as Smiley faces. I have attempted to use HTML symbol codes to resolve this problem, but u ...

Creating a separate CSS file for a CSS class that sets the width of a <div

I am looking to enhance a div element by incorporating a specific class from a separate CSS file. For example, my HTML file contains the following snippet: /* width 90% */ @media (min-width: 960px) { div.width90 { max-width: 90%; } } <div cl ...

Tips for closing the navbar by clicking elsewhere on the page

Is there a way to modify my code in order for the navbar to close when clicking outside of it, while staying open if something inside it is clicked? $(document).ready(function() { $('.nav-btn').on('click', function() { $('.na ...

Leap over in a similar fashion to the provided demonstration

In my attempt to create a unique project, I have created this CodePen example. The goal is to have one ball on the circle that remains in a fixed position, while another rotating main ball must avoid touching it at all costs. Points are awarded for success ...