Z-index ordering for menus containing submenus

I'm trying to create a menu with animated submenus that slide in from the left side of the page. However, no matter what z-index I assign to my submenu, it always appears on top of my content. I positioned my submenu 150px to the left to show the overlap. When I set the z-index of my submenu to -1, it behaves as expected but becomes unclickable. You can see an example live at . Here is the CSS for my main navigation:

nav{
    position:fixed;
    z-index:100;
    width:250px;
    height:100%;
    background:#263b56;
    font-family: 'Oswald', sans-serif;
    color:#fff;
    text-align:center;
}

And here is the CSS for my submenu:

nav ul#NavMenu ul.NavSubMenu{
    position:fixed;
    z-index:99;
    left:0;
    top:0;
    width:250px;
    height:100%;
    background:#2e4765;
    color:#fff;
    text-align:left;
}

Below is the entire code snippet for my navigation:

<nav>
    <ul id="LangNav">
        <li><a href="/hr">HR</a></li>
        <li><a href="/en">EN</a></li>
        <li><a href="/de">DE</a></li>
        <li><a href="/it">IT</a></li>
    </ul>
    <ul id="SocialNav">
        <li><a href="/hr"><i class="fa fa-facebook"></i></a></li>
        <li><a href="/it"><i class="fa fa-twitter"></i></a></li>
    </ul>
    <div id="LogoNav">
        <a href="#"><img src="/images/Logo.png"></a>
    </div>
    <div id="MenuNavBox">
        <ul id="MenuNav">
            <li><a href="/hr">Home</a></li>
            <li><a href="#">Top Level Link</a>
                <ul class="NavSubMenu">
                    <div><i class="fa fa-chevron-left"></i><p class="clear"></p></div>
                    <h1>Privlaka</h1>
                    <li><a href="#">Second Level Link</a></li>
                    <li><a href="#">Second Level Link Level Link Level Link</a></li>
                    <li><a href="#">Second Level Link</a></li>
                </ul></li>
            <li><a href="/en">Privlaka</a>
                <ul class="NavSubMenu">
                    <div><i class="fa fa-chevron-left"></i><p class="clear"></p></div>
                    <h1>Nin</h1>
                    <li><a href="#">Second Level Link</a></li>
                    <li><a href="#">Second Level Link Level Link Level Link</a></li>
                    <li><a href="#">Second Level Link</a></li>
                </ul></li>
            <li><a href="/de">Event Calendar</a></li>
            <li><a href="/it">Accommodation</a></li>
            <li><a href="/hr">Active Holidays</a></li>
            <li><a href="/en">Media</a></li>
            <li><a href="/de">Info</a></li>
            <li><a href="/it">Contact</a></li>
        </ul>
    </div>
    <div id="InfoNav">
        <p><i class="fa fa-mobile" style="font-size:35px;"></i> +385 (0)23 367 468</p>
        <p><i class="fa fa-envelope-o" style="font-size:25px;"></i> <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="2e5a5441005e5c4758424f454f6e544a005a034d414300465c">[email protected]</a></p>
    </div>
</nav>

Answer №1

After experimenting, I found a solution:

nav ul#NavMeni ul.NavPodMeni{
    position: -1;
}

Interestingly, the submenu items in Chrome and Firefox can be clicked without any issues (even when the submenu is positioned to the right). It seems like the problem may be specific to your browser.

Regardless, here are two links that might be helpful:

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

Avoiding the selection of HTML canvas objects

I am currently working on customizing my homepage with an interactive animation. However, I am facing some challenges in integrating it seamlessly into the page. You can view the progress at . My main issue is preventing the canvas object from being select ...

Adding a translucent overlay on top of a background image within a div, while keeping the text on top

Here is the current code that I am working with: <div class="square"> <div id="wrapper"> <h2>Text</h2> <h3>Text</h3> </div> </div> .square { padding: 10px; width: 150px; height ...

To style a checkbox with an image (such as a checkmark or X) using CSS and HTML while hovering over it

Hey there, I'm interested in playing around with HTML and CSS while learning. I have a question: is it possible to add an image to a checkbox when it's hovered over? Just to be clear, I only want the image to appear when the checkbox is being hov ...

Designing rectangular divs with arrow elements

As I delve deeper into the world of CSS, my experiments have been yielding exciting results! From creating popup boxes to playing around with CSS styling, it's been a fun journey so far. However, I'm eager to challenge myself and expand my knowle ...

Verification of user input in open-text fields

After conducting extensive research on form validation in PHP, I realized that most tutorials focus on validating specific fields such as names, emails, or dates using regex. However, I am facing a challenge when it comes to validating free-form fields lik ...

Numerous volume sliders catering to individual audio players

I'm currently working on implementing volume sliders for multiple audio players, similar to what you can find on . With the help of Deepak, I've managed to create code that allows me to control play/pause and adjust the volume of various audio pl ...

Why are static files failing to load on my live Django server when they work fine locally?

My Django website, running version 1.11.29, is failing to load the CSS and JS scripts from the static folder on the live server. Strangely, everything loads properly when I run it locally. Any suggestions? The path to the CSS file appears to be correct, b ...

The ease of use and availability of radio buttons

When clicking on the first or second value of the radio button, it selects the first option. Here is the HTML code: @supports(-webkit-appearance: none) or (-moz-appearance: none) { input[type='radio'], input[type='checkbox'] { ...

Generate a hyperlink within a paragraph

Can anyone provide tips on how to turn a string from Json into a paragraph with a hyperlink included? <p>Dumy Dumy Dumy Dumy Dumy Dumy Dumy DumyDumyDumyDumy abc.com </p> Currently, the paragraph displays as is, but I would like to make abc.c ...

The Ajax request encountered a syntax error due to an unexpected token '<'

I have searched the forum extensively for similar questions, but unfortunately haven't found a suitable answer for my specific problem. In my jQuery code, I am attempting to make an AJAX call using the following snippet: function submitForm(formData) ...

Exploring the Fusion of Different Styles in Material-UI Using React

I have two different styles that I use in my code. One style is specific to certain components, while the other style is global and used across various components. For example, consider the following file tree: index.tsx -App.tsx -globalConstants.ts In ...

Adapting JavaScript functions from IE to work on Firefox and Chrome: A comprehensive guide

I have encountered an issue with a function that retrieves the selected text range within a contenteditable div. While it works perfectly fine in Internet Explorer, it doesn't seem to work in Firefox and Chrome. Could someone kindly provide guidance ...

Looping through an array of objects in VueJS can become a bit tricky when dealing with objects whose properties are dynamic. How can I efficiently

I am looking to create a matrix display from an array of objects, but the properties of the objects may change over time. Here is an example of the data: [ { location: "Japan", webhookStatus: "Up", authenticationStatus: &q ...

Matching start and end of CSS selectors using regex

If I have elements with a title attribute like the examples below, how can I select the div with the title custom-marker-wqs-tailrace bbu-l2 using a CSS regex selector? <div title="custom-marker-awlr-tailrace bbu-l2"></div> <div ti ...

Challenges with incorporating numerous text boxes in real time

There are two text boxes side by side with a "+" sign next to each. When the plus sign is clicked, a new text box appears with both the "+" and "-" signs for adding and removing the text box. I followed instructions from this resource to create my text box ...

What is the most efficient method for tallying the occurrences of the character "." in a webpage?

I am looking to analyze the content of an html page and tally up the occurrences of "." (period). Below is a snippet of code that accomplishes this task by reading the html and displaying the desired results. While considering modifying the existing code, ...

Changing the background color dynamically of a table header in Angular Material

I have utilized the angular material table following this example. https://stackblitz.com/angular/jejeknenmgr?file=src%2Fapp%2Ftable-basic-example.ts In this case, I modified the heading color with the following CSS code. .mat-header-cell { backgrou ...

Retrieve every HTML element that is currently visible on the screen as a result

I have a dynamic HTML table that updates frequently, with the potential for over 1000 rows. Instead of replacing the entire table each time it updates, I am exploring options to only update the visible rows. My initial approach involved iterating through ...

The webpage you are looking for could not be located (HTML, bootstrap 4)

I've followed the correct process by using the # sign before the ID to make the navbar link work. However, I'm still encountering an issue where "Your file was not found" keeps appearing. Here are the HTML codes I've used: < !-- Nav Ba ...

"Customizing the website's font: A step-by-step guide to replacing the default Roboto font with a custom font

Despite my efforts to globally override the font, I am still encountering instances where the Roboto font is not being replaced, particularly on MUI select and autocomplete components. import { createTheme } from '@material-ui/core/styles'; // A ...