When it comes to creating a CSS drop-down menu, don't forget to incorporate an additional <ul

I've created a drop-down menu using CSS with 5 visible list items. When hovering over one of the list items, it highlights and triggers a drop-down effect to display another list underneath. Essentially, you have an initial set of options, and upon hovering over them, a secondary set of options is revealed. I now want to add a tertiary set of options that appears when hovering over the second set, positioned to the right.

For reference, here is what I aim to achieve:

Below is my HTML code. Please note that the text inside the list items is temporary and will be updated later:

<li><a href="#">Home</a>
<ul class="subforums">
<li><a href="#">Elite's</a></li>
<li><a href="#">Newbs</a></li>
<li><a href="#">Subscribers</a></li>
</ul>
</li>
<li><a href="#">Samples</a>
<ul class="subsites">
<li><a href="#">Architecture</a></li>
<li><a href="#">Furniture</a></li>
</ul>
</li>
<li><a href="#">Workshop</a>
<ul class="subcontactus">
<li><a href="#">By Phone</a></li>
<li><a href="#">By e-mail</a></li>
<li><a href="#">By Text</a></li>
</ul>
</li>
<li><a href="#">About</a>
<ul class="subabout">
<li><a href="#">The Team</a></li>
<li><a href="#">Our Story</a></li>
<li><a href="#">Our Goal</a></li>
</ul>
</li>
<li><a href="#">Contact Us</a>
<ul class="subsignup">
<li><a href="#">Find Out More</a></li>
<li><a href="#">Costs</a></li>
<li><a href="#">Paying Methods</a></li>
</ul>
</li>
</ul>

Please refer to the CSS below:

The ID for the main ul element of the whole menu is "navmenu"

#navmenu, #navmenu ul{
list-style-type: none;
}
#navmenu li{
width: 125px;
text-align: center;
position: relative;
float: left;
margin-right: 4px;
}
#navmenu a{
text-decoration: none;
display: block;
width: 125px;
height: 25px;
line-height: 25px;
background-color: #00cff0;
border: 1px solid #ccc;
border-radius: 5px;
color: white;
}
#navmenu li:hover > a{
background-color: #00d3f5;
}
#navmenu li:hover a:hover{
font-size: 105%;
}
#navmenu ul{
display: block;
position:absolute;
top: 26px;
left: 0;
visibility: hidden;
margin: 0;
padding: 0;
}
#navmenu li:hover ul{
visibility: visible;
}
#navmenu{
margin: auto;
width: 700px;
}

I trust this explanation is clear, and I would greatly appreciate any guidance you can provide. Thank you for your time!

Answer №1

View Demo Here

To properly style your navigation menu, make sure to include the following classes in your CSS:

ul#navmenu li ul li ul {
    list-style-type: none;
    position: absolute;
    display: none;
    left: 0;
    margin: -26px 0 0 127px;
    padding: 0;
}
ul#navmenu li ul li:hover ul {
    display: block;
}

You can also check out your code on JSFiddle

Answer №2

If it is of any value to you, I created this FIDDLE a few days ago in response to a similar question.

<div id="menu">
  <ul>
    <li><a href="index.php">Home</a></li>
    <li><a href="#">Link 2</a>
      <ul class="submenu">
        <li><a href="#">Link 2.1</a></li>
        <li><a href="#">Link 2.2</a></li>
        <li><a href="#">Link 2.3</a></li>
        <li><a href="#">Link 2.4</a></li>
        <li><a href="#">Link 2.5</a></li>
      </ul>
    </li>
    <li><a href="#">Link 3</a>
      <ul class="submenu">
        <li><a href="#">Link 3.1</a></li>
        <li><a href="#">Link 3.2</a></li>
        <li><a href="#">Link 3.3</a></li>
        <li><a href="#">Link 3.4</a></li>
        <li><a href="#">Link 3.5</a>
          <ul class="sub-submenu">
            <li><a href="#">Link 3.5.1</a></li>
            <li><a href="#">Link 3.5.2</a></li>
            <li><a href="#">Link 3.5.3</a></li>
            <li><a href="#">Link 3.5.4</a></li>
            <li><a href="#">Link 3.5.5</a></li>
          </ul> 
        </li>
      </ul>
    </li>
    <li><a href="#">Link 4</a></li>
    <li><a href="#">Link 5</a></li>
  </ul>
</div>

#menu {
  background: #333;
  width: 960px;
  margin: 0 auto;
  height: 30px;
}
#menu ul {
  list-style: none;
}
#menu ul li {
  float: left;
}
#menu ul li a {
  display: block;
  height: 25px;
  padding: 5px 10px 0 10px;
  font-family: Verdana;
  font-size: 16px;
  letter-spacing: 1px;
  text-decoration: none;
  color: #fff;
  text-shadow: 1px 1px 0 #252525;
  transition: all 0.2s linear;
}
#menu ul li a:hover {
  background: #555;
  color: #00aeff;
}
#menu ul li .submenu {
  background: #333;
  position: absolute;
  display: none;
  top: 46px;
  margin-left: 0;
  padding: 0;
  width: 150px;    
}
#menu ul li:hover .submenu {
  display: block;
}
#menu ul li .submenu li {
  margin-bottom: 5px;
  width: 100%;
}
#menu ul li .submenu li .sub-submenu {
  background: #333;
  position: absolute;
  display: none;
  left: 0;
  margin: -30px 0 0 150px;
  padding: 0;
  width: 150px;    
}
#menu ul li .submenu li:hover .sub-submenu {
  display: block;
}

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 PHP with Slim PHP Framework to dynamically include CSS files in the header of a document

I have developed a sleek application featuring a login form, dashboard, registration page, and account page. Each of these pages has its own unique route. To maintain consistency across all pages, I have included a shared header and footer by inserting < ...

Why is my background image also rotating when I rotate the text using 'transform: rotate'?

I have been attempting to rotate text on a background-image, but I am facing an issue where my background image also moves with the text rotation. Can someone explain why this is happening? Below is the code snippet: HTML code snippet: <ul> <li ...

Choose Your Price - Price Grids

I need to incorporate two sets of pricing columns into a website. The first set is for regular car cleaning prices, while the second set is for larger cars with slightly higher prices. My idea is to have two buttons at the top – one for regular cars and ...

Images are not visible when scrolling horizontally

Hello everyone, this is my first time reaching out with a question here! I've been working on setting up a horizontal scroll feature and I'm almost there, but I'm encountering an issue where the scroll bar is appearing at the bottom of the ...

Use column formatting for the table's body section

I have written the code below in HTML to create a table. I am looking to apply a specific style to the table body elements in a column that has been assigned a CSS class, while excluding the header columns from this style application. As an example, I hav ...

"Utilizing Bootstrap for a Dynamic Display: Implementing Multiple Carousels with Multiple Images within

I have incorporated several Bootstrap carousels on one page, each with its own unique identifier. These carousels are generated dynamically based on user interactions, such as uploading images. My goal is to display 3 images at once in each carousel. I am ...

What is the best way to make an element disappear 5 seconds after the mouse has stopped hovering

#section1 { display: block; } #section2 { display: none; } #container:hover > #section2 { display: block; } <div id="container"> <div id="section1">Section1</div> <div id="section2">Section2</div> </div> ...

Escape sequences do not seem to be functioning properly when using innerHTML

I am facing an issue where a string containing HTML escape characters (such as < and >) needs to be rendered inside a div using innerHTML. The intention is for the escaped characters to appear as text rather than as actual HTML, but they still render ...

Wrapping HTML input elements in a div for alignment

I need help aligning the inputs in my form to match the image provided . I attempted to center the div using <center>, but I am unsure how to properly align the elements based on the image reference. <center> <div> <div& ...

Preventing the submission of form post values by using jQuery remote validation

     Within my form, I have incorporated two submit buttons (save & exit, next) and implemented remote email address duplication checks. Everything is functioning properly, however, upon submission of the form, I am unable to determine which specific s ...

What is the best approach to reverse the selection of <li> elements by utilizing :not() and :contains

I am looking to implement a live search feature using jQuery. Below is the code snippet I have written: $("#searchInput").on("keyup", function () { var searchTerm = $("#searchInput").val(); $('li:contains("' + searchTerm + ' ...

Dynamic manipulation of classes based on user attributes

One thing I've noticed is that certain WordPress themes, like 'Thematic', include user-specific classes in the body element to avoid using CSS browser hacks. For example: wordpress y2010 m02 d26 h05 home singular slug-home page pageid-94 pa ...

Ensure that the flex item expands to occupy the vacant space left when other child elements are deleted

I am facing an issue with multiple children inside a parent container that has the CSS properties display: flex and flex-direction: column. There is a toggle button on the webpage which removes one of the children when clicked. The problem I need to solv ...

:host-selector for Angular Material dialog

I am currently working with a dialog component provided by angular-material and I need to customize the appearance of the popup dialog. I am aware that there is some support for styling through the component generation: let dialogRef = dialog.open(MyDi ...

Can CSS be used to create curved dashed lines?

Is it possible to achieve dashed lines similar to the ones highlighted in the images below using only CSS? I have a responsive web page built with Bootstrap, and I need the dashed lines to adjust accordingly when the window width changes. ...

Leverage AngularJS to dynamically load CSS stylesheets using ng-repeat

I have organized my stylesheets into separate modules for each include, and I am trying to dynamically load them. However, I am facing some difficulties as when they are rendered, all I see is the following markup for each sheet that should be loaded: < ...

Issue with jQuery incorrectly calculating height post-refresh

I am currently utilizing jQuery to vertically center various elements on a webpage. Due to lack of support in older versions of IE, I cannot use the table-cell CSS statement. Therefore, I am using jQuery to calculate half of the height and then position it ...

Clarity of visual in a lattice

I'm encountering a small issue with my ExtJS 4.2 MVC application that involves grid and image transparency. Below is a snippet of my grid setup: Ext.define('XProject.view.message.inbox.Grid', { extend: 'Ext.grid.Panel', al ...

How can I improve the empty space in HTML after PHP processing?

Here are the lines displayed in HTML: <a href='http://www.1stheme.dev/?frontiles=1946'> <article class="post-1946 frontiles type-frontiles status-publish hentry Width_1_Height_1 " style="width:326px;height:326px;text-align:left;" id="po ...

Activate anchor classes in several anchor link menus simultaneously

I have a one-page website with multiple menus filled with anchor links. Here is an example of what they look like: <ul> <li><a href="#home" class="active" onclick="closeNav();">Home</a></li> <li><a href="#abo ...