What steps can I take to incorporate a dropdown feature into my existing menu design?

I am currently working on a navigation menu that includes various subjects. One of the subjects is titled Equipment, and when I hover over it, Throwables and Gear appear. However, I now want to add another dropdown menu that opens when I hover over Throwables or Gear. I have tried different approaches, such as adding another ul or li element between the Gear li elements, but each time I attempt this, my entire menu becomes distorted. Despite searching for solutions on YouTube and Google, I haven't been able to achieve the desired outcome.

In summary: I would like to implement an additional dropdown menu that appears when hovering over Throwables or Gear. The new menu should open to the right and maintain the same blue color when hovered over. Here is an example of how I envision it looking (with the rest of the menu positioned to the left of Equipment).

Here is a snippet of the menu code:

.navigatie_menu{
  position: absolute;
  left: 505px;
  top: 95px;
  z-index: 2;
}

ul {
  padding: 0px;
  list-style: none;
  color: black;
}

ul li {
  float: left;
  width: 130px;
  height: 40px;
  background: rgba(223,223,223,0.95);
  line-height: 40px;
  text-align: center;
  font-size: 17px;
  color: black;
}

    ul li a {
  text-decoration: none;
  color: black;
  display: block; 
}

ul li a:hover {
  background-color: #94bfea;
}

ul li ul li {
  display: none;
}

ul li:hover ul li {
  display: block;
}
<ul class="navigatie_menu">
  <li><a>Equipment</a>
    <ul>
      <li><a href="Equipment/Gear.html">Gear</a></li>
      <li><a href="Equipment/Throwables.html">Throwables</a></li>
    </ul>
  </li>
</ul>

Answer №1

Is this what you had in mind?

        .navigation_menu {
            position: absolute;
            left: 505px;
            top: 95px;
            z-index: 2;
        }

        ul {
            padding: 0px;
            list-style: none;
            color: black;
        }

        ul li {
            float: left;
            width: 130px;
            height: 40px;
            background: rgba(223, 223, 223, 0.95);
            line-height: 40px;
            text-align: center;
            font-size: 17px;
            color: black;
        }

        ul li a {
            text-decoration: none;
            color: black;
            display: block;
        }

        ul li a:hover {
            background-color: #94bfea;
            display: block;
        }

        ul li ul li {
            display: none;
        }

        ul li:hover ul li {
            display: block;
        }

        .sub_menu1 {
            position: absolute;
            left: 130px;
            display: none;
        }

        .sub_menu2 {
            position: absolute;
            left: 130px;
            display: none;
        }


        .gear:hover .sub_menu1 {
            display: block;
        }

        .throwables:hover .sub_menu2 {
            display: block;
        }
<body>
    <ul class="navigatie_menu">
        <li><a>Equipment</a>
            <ul>
                <li class="gear"><a href="Equipment/Gear.html">Gear</a>
                    <ul class="sub_menu1">
                        <li><a href="#">subject1</a></li>
                        <li><a href="#">subject2</a></li>
                        <li><a href="#">subject3</a></li>
                        <li><a href="#">subject4</a></li>
                    </ul>
                </li>
                <li class="throwables"><a href="Equipment/Throwables.html">Throwables</a>
                    <ul class="sub_menu2">
                        <li><a href="#">subject1</a></li>
                        <li><a href="#">subject2</a></li>
                        <li><a href="#">subject3</a></li>
                        <li><a href="#">subject4</a></li>
                    </ul>
                </li>
            </ul>
        </li>
    </ul>

</body>

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

Modify the button input value within a PHP script

I am currently working on a piece of code that involves following different users and inserting values from a MySQL table. <td align="center"> <input type="button" name="<?php echo $id; ?>" id="<?php ech ...

Is it possible to hide a fixed header on scroll in a mobile device?

I am facing an issue with my Wordpress site where I want the header to hide when the user scrolls. Despite trying various codes, I have been unable to make it work. The reason for wanting to hide the header is that on mobile devices, it causes scroll prob ...

Stop the click event from firing on child elements of a parent element that is currently being dragged

Below is the structure of a UL tag in my code: <ul ondrop="drop(event)" ondragover="allowDrop(event)"> <li class="item" draggable="true" ondragstart="dragStart(event)" ondrag="dragging(event)"> <div class="product-infos"> ...

Locate the closing anchor tag following the image

I need to locate the closing anchor tag that wraps an image with the class name "cat-image" in order to move a div right after it. However, I am unable to modify the HTML by adding IDs or classes to the anchor or image tags. Below is an example of the HTM ...

Using Angular expressions, you can dynamically add strings to HTML based on conditions

I currently have the following piece of code: <div>{{animalType}}</div> This outputs dog. Is there a way to conditionally add an 's' if the value of animalType is anything other than dog? I attempted the following, but it did not ...

How can I include line breaks using HTML `<br>` tags in a textarea field that is filled with data from a MySQL

Within a modal, I am showcasing a log inside a read-only <textarea> field that contains data fetched from my MySQL database. Below this, there is a writable <textarea> field where users can input updates to the log, which are then added to the ...

Modifying the Placeholder Color in a Material UI Autocomplete: Tips and Tricks

In my team, we are working on two projects that both utilize an internal library with a header containing a search box. In one project, the placeholder text "Search" displays normally. https://i.stack.imgur.com/lhL5V.png However, in the second project wh ...

Ways to Ensure the Footer Stays Beneath Your Image Gallery

After successfully keeping the footer at the bottom of other pages on my website, I'm facing a challenge with my photo gallery page. The footer stubbornly sits in the middle of the page. :( This is the HTML code for that particular page: html { ...

Troubleshooting problem with sorting in Angular 4 material header

Using Angular 4 material for a table has presented me with two issues: 1. When sorting a table, it displays the description of the sorting order in the header. I would like to remove this. It displays "Sorted by ascending order" here. The ngx modal theme ...

Position an element to the right within a div using the float property

My product page features a range of attributes that can vary from 1 to 4, each sharing a common fieldset class name. I am attempting to position two of the fieldsets side by side and the remaining ones below them in a similar layout. However, achieving thi ...

The initial menu option stands out due to its unique appearance, created using the :first-child

I am currently designing a website menu and I would like the .current-menu-item - current item, to have a different appearance. However, I want the first item in this menu to have rounded corners (top left, bottom left). How can I achieve this using the :f ...

Accessing web authentication through VBA

Having some difficulties trying to access my webtext account through VBA. The first hurdle I faced was identifying the tags for the username and password input boxes. After using inspect elements, it seems like the tags are "username" and "password." Howe ...

Another approach to utilize JavaScript for populating content into a <div> container?

Upon loading the page, I aim to display a message in the <div> element. Below is the HTML and JavaScript code I have implemented: <body onload="printMsg()"> <div id="write"></div> </body> function printMsg() { var no ...

What is the best way to transfer a user-generated PNG file to my backend server?

I'm in the process of developing a website that enables users to generate personalized graphics and easily download them directly from the platform. My approach involves allowing users to customize an svg using a javascript-powered form, which is the ...

Rows in the table are not extending to their full length

I'm having an issue with my Bootstrap table design. I have 8 header cells and 5 body cells, but the rows are only stretching across 4 columns. I've hit a blank trying to figure out why. <script src="https://cdnjs.cloudflare.com/ajax/libs/jq ...

Tips for maintaining an organized layout of buttons on a compact screen

When the following HTML code is executed on a small screen, one or more buttons will naturally shift to the "lower line" in order to adjust to the screen size. While this may seem like a good thing initially, unfortunately, any button that moves down a row ...

Is There a Glitch in IE9? Unexplained Expansion of DIV Element

Here is a small code sample that I have: <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title>Test</title> <style type="text/css"> table.Sample { width: 600px; table-layout: fixed; } table.Sample ...

Creating form elements without utilizing the <form action: MAILTO:> attribute

I'm in the process of designing a website with a side bar that features a form on every page. I'm looking for a way to have the form information submitted to an email address without using the action: MAILTO:? Would it be possible to create a sep ...

What are the advantages and disadvantages of using the picture element in web design?

What advantages and disadvantages come with using the HTML5 picture element? Specifically, does the browser download all images or only the image that matches the media query? ...

I'm seeking guidance on how to delete a specific ul li element by its id after making an ajax request to delete a corresponding row in MySQL database. I'm unsure about the correct placement for the jQuery

I have created an app that displays a list of income items. Each item is contained within an li element with a unique id, along with the item description and a small trash icon. Currently, I have implemented code that triggers an AJAX call when the user cl ...