Hierarchy Navigation Menu

As someone new to the world of JavaScript and CSS, I have been experimenting with adding a menu from an example on W3Schools. The code is functioning correctly, but now I'm looking to take it a step further by creating a multi-level menu with 2 levels. I've attempted this on my own without success. I would greatly appreciate any advice or suggestions from the experts here. Thank you in advance.

<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<style>
body {
  font-family: Arial, Helvetica, sans-serif;
  margin: 0;
}

.navbar {
  overflow: hidden;
  background-color: #333; 
}

.navbar a {
  float: left;
  font-size: 16px;
  color: white;
  text-align: center;
  padding: 14px 16px;
  text-decoration: none;
}
  
.subnav {
...

Answer №1

.subnav:hover .subnav-content, .subnav1:hover .subnav-content1 {
  display: block;
}

To ensure proper functionality, make sure to include the CSS for both subnav1 and subnav-content1 classes.

Check out this link for a working example

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

Overlapping columns with bootstrap images

Struggling to make three images responsive using Bootstrap columns. While they appear responsive, the issue is that the images overlap, except for the last column which displays correctly. <div class="row"> <div class="col-sm-2 offset-sm-3" ...

A method to eliminate the mouse-over effect following the selection of an input box

Currently, I am utilizing Angular and encountering three specific requirements. Initially, there is an input box where I aim to display a placeholder upon pageload as 'TEXT1'. This placeholder should then toggle on mouse hover to display 'TE ...

Utilizing values from .properties files in Java with Spring for internationalization: A straightforward approach to handle Strings

Here is the code snippet I am using: @Value("${app.user.root}") private String userRoot; This code helps me to fetch a constant value from my application.properties file. Within my GetMapping method, I need to redirect to the error page and pass a S ...

Unveiling the steps to seamlessly publish JSON data from a URL to Pubnub

i have retrieved some JSON data from this specific URL how can i publish this information to Pubnub? i've prepared a real-time Graph using a code snippet, but the input is static. I aim to dynamically fetch data from a URL <html> <head> ...

The error remains a mystery to the console - could it be possibly linked to the onclick() method?

Despite checking thoroughly, the console remains empty. I came across this code in a video tutorial where it worked perfectly. Below is the simple code that I am currently using: function addItem() { inames = [] iqtyp = [] iprice = [] inames.pu ...

Tips on applying array values as styles to a div element

I have a list of numbers stored in an array and an equal number of div elements. I need to assign each value from the array to a corresponding div. var xList = [265, 152, 364] var yList = [125, 452, 215] All div elements have the same class name. function ...

Performing a function when the ondrop event of a <li> element is triggered

Is there a way to trigger a code-behind click function on the ondrop event of an <li> element? Additionally, I would like to know if it's possible to force a postback on the onclick event. Any ideas on how to achieve this? Just to clarify, thi ...

Tips for positioning text, video, and images using HTML

I'm currently working on a webpage and trying to figure out how to align an "index" box on the left side and a video on the right. My goal is to have the video box positioned right next to the index box. Any ideas on how I can achieve this? I'v ...

Using Bootstrap4 container-fluid on elements other than the "div" tag

For my Bootstrap 4 alpha 5 project: I am experimenting with using the .container-fluid class on HTML elements that are not divs. However, I have noticed a change in output when applying it to non-div elements. My main objective is to create custom CSS for ...

What is the best way to reveal the menu options by tapping on the top left icon?

Seeking guidance on how to activate the menu by clicking the top left corner icon. A sample code setup is available in Codepen through this link: https://codepen.io/RSH87/pen/rmgYbo. I require assistance with incorporating the JavaScript file into my React ...

Experiencing data loss while utilizing BeautifulSoup

I am currently working on a tutorial from the book 'Automate the Boring Stuff with Python' where I am practicing a project titled 'Project: “I’m Feeling Lucky” Google Search' Unfortunately, the CSS selector used in the project is ...

Maintain a specific number of decimal places while incrementing by a specific value

I've been developing a timer that specifically counts decimals in intervals of 1/30 (meaning the only decimals allowed are .x00, .x33, .x67). Everything has been running smoothly so far, but there's one thing that really bothers me - when the de ...

The Angular method for retrieving the child's ID when it is clicked

As a newcomer to Angular 1.0 with a background in jQuery, I am facing the following scenario: Let's imagine we have the following HTML structure : <div id="filters"> <div id="filter1">Filter 1</div> <div id="filter2"> ...

What is the process for resetting a JQueryUI effect animation?

I'm facing an issue with two timer bars that each wind down over a 5-second period. When I try to stop and reset the first timer, it simply continues from where it left off instead of resetting. The desired behavior is as follows: Timer1 starts User ...

Is it time to advance to the next input field when reaching the maxLength?

In my Vue form, I have designed a combined input field for entering a phone number for styling purposes. The issue I am facing is that the user needs to press the tab key to move to the next input field of the phone number. Is there a way to automaticall ...

Adding a space after a comma automatically upon saving changes in VSCode

Whenever I input code (t,s) into the system and make changes to it, it automatically transforms into (t, s) with an added space after the comma. Is there a way to avoid VScode from adding this extra space on its own? ...

Select the image to be taken to a new page where the chosen image will be seamlessly integrated into the new layout

Imagine I'm in the process of developing a fictional online guitar store. A crucial feature on my homepage is an image carousel, and I want users to be able to click on these images and seamlessly transition to a product page showcasing more details a ...

Flask caches JSON files automatically

I am currently working on a visualization app using js and python. The functionality of my app is as follows: There is a textbox in the browser where I input an URL The URL is then sent to Python via Flask In Python, the URL is processed to create ...

What are the steps to create a dynamic background image that adjusts to various

When viewing the website on a computer screen, the entire cat is visible in the background image. However, when switching to a mobile screen size, only a portion of the cat is displayed, appearing as though it has been cut off. The image is not smaller on ...

How can I deselect the 'select-all' checkbox when any of the child checkboxes are unchecked?

Here is the code provided where clicking on the select-all checkbox will check or uncheck all child checkboxes. If any child checkbox is deselected, the 'select-all' checkbox should also be unchecked. How can this be achieved? $(document).read ...