When the drop-down menu is open and you hover your mouse over an item, the drop-down menu will automatically

Creating a drop-down menu using HTML:

<ul>
  <li><a href="index.php">Home</a></li>
   <li><a href="#blog">Blog</a></li>
    <li><a href="#features">Services</a></li>
    <li><a href="#gallery">Projects</a></li>
    <li id="list"><a>Our Services</a></li> //on hover dropdown menu open
      //dropdown menu start
                <li class="dropbtn"><a href="iphone_app_development.html">IPhone App Development</a></li>
                   <li class="dropbtn"><a href="andriod_app_development.html">Android App Development</a></li>
                 <li class="dropbtn"><a href="website_development.html">Website Development</a></li>
                     <li class="dropbtn"><a href="graphics_designing.html">Graphics Designing 
                     </a></li>
                     <li class="dropbtn"><a href="game_development.html">Game Development </a>
                     </li>
                    <li class="dropbtn"><a href="it_security.html">IT Security</a></li>
                    <li class="dropbtn"><a href="virtual_reality.html">Virtual Reality</a></li>
//dropmenu end

            <li><a href="#testimonial">Client's Reviews</a></li>
            <li><a href="#contact">Contact us</a></li>
        </ul>

CSS code for the drop-down menu:

.dropbtn
{
    display: none;
}
#list:hover ~ .dropbtn
{
    display:block;
}

Although the drop-down menu is functioning correctly, an issue arises when hovering over the items in the dropdown menu. All items hide upon hover. How can I select a specific option between IPHONE to Virtual Reality without this issue?

Answer №1

Make sure to enclose the sub-menu within a nested ul

.dropbtn
{
    display: none;
}
#list:hover  ul#tset .dropbtn
{    display:block;
}
 
<ul>
<li><a href="index.php">Home</a></li>
<li><a href="#blog">Blog</a></li>
<li><a href="#features">Services</a></li>
<li><a href="#gallery">Projects</a></li>
    <li id="list"><a>Our Services</a> 
      <!--dropdown menu start-->
        <ul id="tset">
<li class="dropbtn"><a href="iphone_app_development.html">IPhone App Development</a></li>
<li class="dropbtn"><a href="andriod_app_development.html">Android App Development</a></li>
<li class="dropbtn"><a href="website_development.html">Website Development</a></li>
<li class="dropbtn"><a href="graphics_designing.html">Graphics Designing 
</a></li>
<li class="dropbtn"><a href="game_development.html">Game Development </a>
</li>
<li class="dropbtn"><a href="it_security.html">IT Security</a></li>
<li class="dropbtn"><a href="virtual_reality.html">Virtual Reality</a></li>
</ul>
</li>
<!--//dropmenu end-->

<li><a href="#testimonial">Client's Reviews</a></li>
<li><a href="#contact">Contact us</a></li>
  </ul>

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

Incorporating ASP includes within an HTML file

Is there a method to utilize ASP or ASP.NET for including HTML in another HTML file, similar to PHP includes with HTML and the AddType handler in .htaccess? I am exploring options for updating navigation on a Windows server that does not have PHP installe ...

Switching images between mobile and desktop view in responsive mode is a useful feature for optimizing

Within a specific folder structure, I have a collection of images designated for both desktop and mobile displays: img: img-1.png img-2.png img-3.png img-4.png img-5.png img-6.png img/mobile: img-1.png img-2.png ...

adhesive section on the left side with a defined lower boundary

I have a contact div that I made sticky using Bootstrap affix. <div id="contactForm" data-spy="affix" data-offset-top="400"> However, I am unsure of how to limit its bottom to the top of the next div. In other words, I want it to stay in place when ...

How to detect a disconnected socket in Node.js using websockets

Encountering an issue with my nodejs websocket server. Upon graceful termination of client connections, the onclose method is triggered for closed sockets where I conduct clean up tasks. However, when clients disconnect due to network issues, the onclose ...

Adjust the width of the unordered list to match the width of its widest child element

I'm encountering a minor issue with displaying a ul element as I am just starting to learn CSS. My goal is to set the width of my ul to match the widest listitem it contains. Below is the HTML code I have used: <div id="sidebar"> <ul i ...

Impact of designs on the elements within components

Here's a CSS query I have: If I have the code below, does the styling apply to the contents of v-container but not v-container itself? <v-app id="inspire"> <v-container justify-center style="max-width: 1200px"> <v-layout row ...

Creating a multi-line form in Python Django involves defining a form

Brand new to Django and currently working on creating a form within a page. The form consists of multiple fields, all of which are currently displayed in a single line on the page. This is the code snippet I am using in the template: <form action=&apos ...

I customized the navbar in Bootstrap by centering it with custom CSS, but whenever I click on it, it suddenly shifts to one side. I'm puzzled as to why this is happening and

I attempted to center my navbar-toggler element, but was only successful in centering the navbar-contend using Bootstrap. I then took it a step further by trying to center the navbar-toggler icon with custom CSS, however, it now shifts to the left when cli ...

having difficulty retrieving website content using the ui.router

This is my HTML code: <!doctype Html> <html lang="en"> <head > <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/l ...

Guide to implementing input fields in a form in React.js when the user chooses the "Other" option from a dropdown menu

For my project, I have implemented a multi-select dropdown input feature that saves all selected items in a useState array when the user clicks on the add icon. However, I am facing an issue where I need to render an input field only when the "Other" optio ...

Eliminating blank spaces below or above images when displayed horizontally

Displayed below is the image depicting my problem: I have discovered a cumbersome method to eliminate this unwanted whitespace by treating it as four separate lists and utilizing a complex for-loop to add elements. However, this approach limits the number ...

webdriver.support.select - Select fails to interact with the element

Hey there, I am encountering an issue with the select element below: <div class="col-xs-12 col-md-6"> <label class="ph_label pointer city"> <span class="l citylbl">City</span> <select class="cities custom-dropdown" data-validati ...

How to select a child element within a sibling div of a parent div using jQuery

HTML <div class="container-fluid"> <div class="input-page">...</div> <!-- field 1 --> <div class="col-md-12 col-sm-12 col-xs-12 no-padding">...</div> <div class="col-md-12 col-sm-12 col-xs-12 no-padding"> ...

I am not familiar with this HTML element, it's a mystery to me

As I develop a data-recollection view in HTML, I've recognized the necessity of creating something similar to this: To elaborate, it's an image created hastily, with an input where users can enter data. When they click the "+" button, another in ...

React Bootstrap's drop-down components with a dark theme

In my react application, I am looking to design a custom navbar for the header using react-bootstrap. Specifically, I need a dark styled NavDropdown that changes background color to #f0ad4e on hover. Despite attempting the following code snippet, I couldn& ...

Customize Bootstrap layout on the fly

I have encountered a slight dilemma. I am attempting to implement something similar to the following: <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/> <script src="https://ajax.googleapis.com ...

Guide to displaying a loading image when selecting an item from a dropdown menu using JavaScript

When using three drop-down lists and performing an AJAX call on each dropdown list's onclick function, I encountered a delay in loading the data. To address this issue, I attempted to display a loading image while processing the AJAX call. <form ...

Attempting to update the content of a specific div element on a webpage without disrupting its current position

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>ajax div example</title> <script type="text/javascript" src="jscripts/jquery-1.6.4.min.js" ...

Obtaining your CSGO inventory via Steam API using jsonp: A step-by-step guide

Hey there! I'm currently facing an issue while trying to access a player's CSGO inventory using Valve's API. Unfortunately, I keep running into the error message stating that no 'access-control-allow-origin' header is present on th ...

Creating a PDF document using HTML code

I am interested in creating a PDF file from an HTML code that includes the stylesheet rules using PHP. Currently, I am attempting to achieve this with the MPDF library. However, the generated PDF does not resemble the original HTML page. Many elements app ...