menu with dropdown options within dropdown options

I am experiencing an issue with creating a nested menu within my navigation header. Specifically, under the "Reports" section, I want to have two submenu items named "Global Shop" and "Ndustrios". When hovering over either of these submenus, additional menu items should appear. However, the problem I am facing is that currently, when hovering over "Reports", all submenu options are displayed at once instead of each individual submenu item showing separately. This means that while "Global Shop" displays its submenu options like Inventory, Sales Orders, etc., "Ndustrios" does not show any submenu items.

Here is what I have attempted:

#nav_ul {
  list-style-type: none;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background-color: #1D3567;
  text-align: center;
}

li {
  display: inline-block;
}

li a,
.dropbtn {
  display: inline-block;
  color: white;
  text-align: center;
  padding: 24px 16px;
  text-decoration: none;
}

.dropdown {
  display: inline-block;
}

.dropdown-content {
  display: none;
  position: absolute;
  background-color: #1D3567;
  min-width: 160px;
  box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2);
  z-index: 1;
}

.dropdown-content a {
  color: White;
  padding: 12px 16px;
  text-decoration: none;
  display: block;
  text-align: left;
}

.dropdown:hover .dropdown-content {
  display: block;
}

.dropdown-content ul {
  display: none;
  position: absolute;
  left: 100%;
  top: 75;
}

.dropdown-content:hover ul {
  display: block;
}
<nav>
  <ul id="nav_ul">
    <li class="dropdown">
      <a href="#Reports">Reports</a>
      <div class="dropdown-content">
        <a href="#GS">Global Shop</a>
        <div class="dropdown-content">
          <a href="Inventory.html">Inventory</a>
          <a href="sales.html">Sales Orders</a>
          <a href="quotes.html">Quotes</a>
          <a href="workOrder.html">Work Orders</a>
          <a href="prtUsed.html">Part Where Used</a>
        </div>
        <a href="#ND">Ndustrios</a>
      </div>
    </li>
  </ul>
  <nav>

Answer №1

I stumbled upon the following code and made some modifications to tailor it to my specific requirements. The nested drop-down functionality is performing flawlessly.

.parent {display: block;position: relative;float: left;line-height:30px;background-color: #1D3567;}
.parent a{margin: 10px;color: #FFFFFF;text-decoration: none;}
.parent:hover > ul {display:block;position:absolute;}
.child {display: none;}
.child li {background-color: #1D3567;line-height: 30px;border-bottom:#CCC 1px solid;border-right:#CCC 1px solid; width:100%;}
.child li a{color: #FFFFFF;}
ul{list-style-type: none;margin: 0;padding: 0px; min-width:15em;}
ul ul ul{left: 100%;top: 0;margin-left:1px;}
li:hover {background-color: #95B4CA;}
.parent li:hover {background-color: #95B4CA;}

<ul id="nav_ul">
  <li class="parent"><a href="#">Home</a></li>
  <li class="parent"><a href="URL">Outlook Web</a></li>
  <li class="parent"><a href="#">Production</a>
    <ul class="child">
        <li class="parent"><a href="URL">South</a></li>
        <li class="parent"><a href="URL">Enclosure Systems</a></li>
        <li class="parent"><a href="URL">South</a></li>
        <li class="parent"><a href="http:">Factory Andon</a></li>
        <li class="parent"><a href="http:">Web Docs</a></li>
    </ul>
</li>
<li class="parent"><a href="#">IT</a>
    <ul class="child">          
        <li><a href="http://kb">Knowledge Base</a></li>
        <li><a href="http:/">Submit a Ticket</a></li>
        <li class="parent"><a href="http:">Archived Links</a></li>
    </ul>
</li>
<li class="parent"><a href="#">Office Directories</a>
    <ul class="child">          
        <li><a href="http://">Hennig</a></li>
        <li><a href="http:/">AME</a></li>
    </ul>
</li>
<li class="parent"><a href="ht">Hennig Parts</a></li>
<li class="parent"><a href="">Factory Andon</a></li>
<li class="parent"><a href="https:">Business Cards</a></li>
<li class="parent"><a href="#">Reports</a>
    <ul class="child">
        <li class="parent"><a href="#">Global Shop<span class="expand">&raquo;</span></a>
            <ul class="child">
                <li><a href="inventory">Inventory Report</a></li>
                <li><a href="sales.">Sales Report</a></li>
                <li><a href="quotes">Quotes Report</a></li>
               <li><a href="workOrder">Work Order Report</a></li>
                <li><a href="prtUsed">Part Where Used Report</a></li>
            </ul>
        </li>
        <li class="parent""><a href="#">Ndustrios<span class="expand">&raquo;</span></a>
        </li>
    </ul>
</li>

Answer №2

To achieve the desired outcome, you will need to restructure your HTML by including another list inside your li element to accommodate more links. However, a significant issue remains unresolved. When you hover over a submenu item and the list shrinks due to no longer being hovered over, you are left with nothing to hover on. For instance, try hovering over "reports," then "global shop," and finally attempt to hover over "Ndustrios." It's impossible as the list shrinks once you leave the drop-down <li> section.

Your two options are: 1. Rearrange Ndustrios above the dropdown or 2. Modify the behavior so that the dropdowns appear upon clicking instead of hovering.

If you insist on using dropdowns within dropdowns, here is an example of combining hover and click functionality. Additionally, the top-level dropdown can also be made clickable using this method.

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

What could be causing my function to execute thrice?

I cannot seem to figure out why my tag cloud is causing the required function to run multiple times instead of just once when I click on a tag. This issue persists whether using jQuery or plain JavaScript. What am I missing? The code I have is very simple, ...

Strangely compressed HTML image

I am facing an issue with using a base64-encoded png retrieved from a server in WebGL. To incorporate the encoded png, I load it into an html Image object. For my specific needs, it is crucial that the png data remains completely lossless, however, I&apos ...

Removing the restriction on maximum width to 100% and allowing for automatic height adjustment

Within my project, I have implemented a CSS technique where all images within a container are set with the attributes max-width: 100%; and height: auto;. This is done to ensure that images scale down appropriately when the viewport and container size decre ...

Centering DIVs both vertically and horizontally within parent DIVs that have a height and width of 100%

I am facing a challenge with my nested parent DIVs that occupy 100% of the browser window in terms of height and width. I am struggling to center secondary DIVs inside their respective parent containers. Here are the definitions for my stacked parents: # ...

Ways to align page title text at the center of the banner image without using flexbox or grid layout?

Seeking advice on how to vertically center the banner text in the middle of the banner image for a CSS-only psd conversion project. Any ideas on achieving this goal without utilizing flexbox or grid? header { background-image: url(../assets/main-ban ...

How can I stop jQuery mobile from updating the document title?

It appears that jQuery mobile automatically uses the text content of data-role="header" to set the document.title. For example: <div data-position="fixed" data-role="header"> <h1>This text</h1> </div> To work around this, I ha ...

Mastering responsive layout design in Nextjs using Tailwind CSS

I am attempting to design a card layout where the image is on the left and the content of the card is on the right using flex in NEXTJS and Tailwind CSS. My goal is to ensure that the image remains responsive. <div className="block"> < ...

The "read more" button seems to be malfunctioning

I've been working on integrating a gallery of images into my posts. My goal is to display 4 images initially, followed by a "load more" button that, when clicked, will reveal another set of 4 images, and so on. I have already created the HTML, CSS, an ...

Resetting an Angular Material select component

I've encountered an issue with Angular Material. Currently, I have a form with two select elements. The problem arises when I choose a value in one of the selects, it resets and loses its value. Could this be a bug? Or am I possibly making a mistake ...

How can we show a React JS component when clicked, without using the App.js file for display?

How can I display a component onclick in React JS without using UseState in a file other than App.js? This code will be in App.js var [clicks, setClicks] = useState(false) return( <> {clicks && &l ...

Should I open the Intel XDK hyperlinks in the default web browser instead of

Lately, I've been developing an HTML5 app on the Intel XDK that includes buttons linking to external websites. However, I'm encountering an issue where the apps open in the same window, leading users to get stuck in the browser. Currently, I am u ...

Is it possible to align a clip-path starting from the right edge?

On my webpage, I have a unique hamburger icon that is positioned 2rem away from the right and top edges. I am looking for a convenient way to create a clip path that grows from its center point. Calculating the center point is not difficult but unfortunate ...

Webpage unable to scroll

Having trouble with scrolling on my webpage and I can't figure out why! The issue is happening when trying to view this page: Within the main file, I have included 2 other php files: <?php include '../../include/menu.php'; inclu ...

The JS Fiddle code fails to function properly once it has been downloaded to the local computer

I came across a helpful example fiddle webpage: jsfiddle.net/yijiang/6FLsM/2 After following examples from others, I attempted to download (right click and Save As) using the latest Chrome browser with the following links: jsfiddle.net/yijiang/6FLsM/2/s ...

Using a global CSS file in Angular can lead to large module bundles being emitted by Webpack

In our Angular application generated with angular-cli, we are utilizing various global styles and imports defined in the styles.scss file (which begins with /* You can add global styles to this file, and also import other style files */ if that sounds fami ...

How to Create a Floating DIV with CSS

Here is the URL I am referring to: Website I want to position the Weather DIV above other content on the page while still maintaining its position when expanded or collapsed. How can I achieve this without affecting the layout of other elements? This is ...

Utilize the CSS exclusively for the specific element

nav ul { } nav ul li { margin-left: 7px; } nav.ul li a, a:link, a:visited { float: left; padding: 7px; margin-left: 15px; color: #ffffff; text-decoration: none; font-weight: bold; } nav ul li a:hover { } The styling above is ...

Angular Material: creating a custom sidenav transition from detailed layouts to icon-based designs seamlessly without the need for predefined

I'm currently working on a <sidenav> that has the ability to toggle between displaying text along with icons or just icons using a menu button. The <sidenav-content> section is set to automatically resize with a smooth transition effect. ...

Expanding the content of a single page by clicking on a separate tab

I have a link on Page A. Page B has two tabs, with the content of tabs 1 and tab 2 currently set to "display:none". I want clicking the hyperlink on page A to automatically open or activate the second tab on page B. I am seeking a solution using JavaScri ...

Using a for loop in JavaScript to fetch and display a specified number of results from an API

Recently, I delved into the world of Javascript and API arrays to grasp the concept of retrieving and manipulating various APIs. The topic of Javascript loops and arrays has been discussed numerous times, both here on StackOverflow and on other platforms. ...