What causes the drop-down menu to disappear when the mouse is no longer hovering over the menu

I am experiencing an issue with my menu bar that has three items with drop down menus. When I hover over the menu bar, the drop down menu appears, but it disappears when I try to move my mouse to select something from the drop down menu. I suspect that there might be a problem in my CSS code, but I'm not entirely sure what it is. Here is the snippet of my CSS code:


body {
  background: url(background.jpg);
  font-family: Georgia;
  margin: 10;
  padding: 10;
}

.main {
  width: 1000px;
  margin: 0 auto;
  background: #000;
  color: #fff;
}

.main > div {
  height: 200px;
  margin: 10px;
}

div.bottom {
  height: 0;
  clear: both;
  margin: 0;
}

.main .head {
  height: 100px;
  color: #fff;
  line-height: 100px;
}

h1 {
  font-size: 30px;
  font-weight: bold;
  margin: 0;
}

h5 {
  color: #000;
}

.main .page {
  min-height: 500px;
  height: auto;
 }

.main .foot {
  height: 70px;
  text-align: center;
  line-height: 70px;
}

.span_1 {
  width: 800px;
}

.span_2 {
  width: 990px;
}

div.menu {
  height: 50px;
  line-height: 50px;
  background: #000;
  color: #fff;
}

.menu a:link,
.menu a:visited {
  color: #000;
  text-decoration: none;
  padding: 0 10px;
}

.menu ul,
.menu li,
.menu h5,
.menu .mega-drop {
  list-style: none;
  margin: 0;
  padding: 10;
  background: #fff;
}

.menu li {
  position: relative;
}

.menu > ul > li {
  float: left;
  border-right: solid 1px;
}

.menu > ul > li > ul {
  position: absolute;
  left: 0;
  top: 60px;
  width: 400px;
  z-index: 1;
  display: none;
}

.menu > ul > li > .mega-drop {
  position: absolute;
  left: 0;
  top: 60px;
  z-index: 1;
  width: 400px;
  display: none;
}

.menu > ul > li > .mega-drop > .mega-drop-column {
  float: left;
  width: 200px;
}

.menu > ul > li > ul > li > ul {
  position: absolute;
  left: 400px;
  top: 0;
  width: 400px;
  z-index: 1;
  display: none;
}

.menu li:hover {
  background: #3f0;
}

.menu li:hover > ul,
.menu li:hover > .mega-drop {
  display: block;
}

Answer №1

To implement this feature, you need to follow these steps:

<div id="menubar"> - this is where you hover to display the menu
    <div id="navpoint1">...</div>
    <div id="navpoint2">...</div>
    <div id="navpoint3">...</div>
    ...
</div>

By continuously hovering over 'menubar', the dropdown menu will stay visible at all times.

Answer №2

I encountered a similar issue and after trying various solutions, I made a small tweak to the code which fixed the problem completely! It was particularly unusual because the issue only surfaced on the homepage!

Initially, the CSS looked like this...

#nav li ul {
width:100%;
margin:0;
padding:0;
display: none;
position: absolute;
top: 100%;
background-color: #39F;
background: rgba(51, 153, 255, .9);
}

After modification, it now reads as follows...

#nav li ul {
width:100%;
margin:0;
padding-top:.2em;
display: none;
position: absolute;
top: 100%;
background-color: #39F;
background: rgba(51, 153, 255, .9);
z-index:99999;
}

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

Traverse through the div elements with identical class using jQuery

Hey there! I have a bunch of classes named itemdata and I'm looking to incorporate some jQuery within each div. Within every div, there is a link that I want to extract the href attribute value from and enclose it within another <span> in that s ...

Seeking guidance on an HTML/CSS dilemma. Any recommendations on how to proceed?

I am in the process of developing a flowchart builder using JavaScript. I need some guidance on how to connect two blocks (divs) with an arrow or line. Take a look at the illustration below ______ | | | DIV x---------------- | | ...

Complete picture in a circular div with aspect ratio

I'm currently working on creating a profile page and I'd like to have an image inside a circular div. The challenge is that I want the image to maintain its aspect ratio, even though the dimensions are unknown and users can upload images of any s ...

Unable to retrieve the iframe variable from the parent as it returns undefined

I am trying to retrieve a variable within an iframe from the parent index.html. Here is the index.html code: <!doctype html> <html lang="en-us> <head> <title>Test</title> </head> <body> <p>Test& ...

Why are the HTML links generated by JS not opening in Chrome?

<a href='http://www.xyz.hu/xyz' alt='Kosár' title='Kosár'>Megtekintés</a> Additionally: - A setInterval function refreshes the sibling's content every second, although it should not affect this specific el ...

How to center a div horizontally within another div using CSS

I'm attempting to center a block element horizontally on my webpage. Here's an illustration of what I'm aiming for: I can't use fixed div dimensions as the design needs to be responsive. Click here for the demo. Below is the HTML co ...

Pressing the dart key will alter the sprite's direction in a 2D game

Recently, I've been working on a Dart game where the user controls a space ship sprite using the W, A, S, and D keys. Pressing these keys will move the sprite up, left, right, and down respectively. Additionally, pressing the Space bar will launch a p ...

Arranging DataTable by the newest date

I need to change the default sorting of a table from old date to recent date (1st column). Here is the code I have been trying: <script> $(document).ready( function () { $('#table_id').DataTable({ dom: 'B<"cle ...

Creating a dynamic page footer for a PDF document using Rotativa's content generation capabilities

As I work on generating a PDF, my employer has requested that I add a footer to each page of the document. Currently, the PDF is being created using Rotativa, where an HTML page is converted into a PDF. However, I am facing a challenge in determining the ...

Discovering the Perfect Color Combinations

Current Admin Panel Themes /** Custom Portlet Color Options **/ .Vibrant-Pink { background: rgb(220, 79, 173); } .Rich-Red { background: rgb(172, 25, 61); } .Bold-Orange { background: rgb(210, 71, 38); } ...

Table for maximizing space within a cell (Internet Explorer 8)

I am attempting to make the "innerTable" fill up all available space within another table. The issue is with IE8 (no compatibility mode, IE8 browser mode, Doc mode IE8 Standards). The table does not expand to fit the containing TD. I tried enclosing the ta ...

Having issues with the presentation of full_numbers pagination in IE while using jQuery dataTables

I am currently utilizing the DataTables jQuery plugin (found at ) with the initialization code below: $('#reconcile_table').dataTable( { 'bSort' : true, 'bFilter' : true, 'bSortClasses' : false, &a ...

Support for a few breakpoints within Bootstrap

I am tasked with creating only 2 breakpoints for a specific application. These 2 breakpoints are <=768 for mobile and >=1280 for desktop. (No Tablet breakpoint) How do I adjust the $grid-breakpoints to accommodate this setup? I think it should be d ...

Using Bootstrap in a Form Dropdown with Thymeleaf in Spring Boot

I'm facing an issue where all the fields in my form are getting values except for the dropdown button using bootstrap. <div class="btn-group"> <button type="button" class="btn btn-warning dropdown-toggle" data-toggle="dropdown" name="gen ...

Incorporate validation features within a jQuery method

I am struggling with some HTML and jQuery code that generates links based on user input. HTML <input type="text" id="text" placeholder="Enter text" autofocus /> <a id="link1" class="btn btn-info" href="#" target="_blank"> Search 1 </a> ...

How to implement a modal popup in Vue.js using an anchor tag

As a newcomer to Vue.js, I'm facing an issue with creating a link in my navbar component that, when clicked, displays a modal component. I've noticed that the solutions I found are for buttons which use the data target attribute, but this isn&apo ...

Is there a way I can utilize a for-loop and if statement in JavaScript to present the information accurately within the table?

My current task involves fetching data via AJAX and then using a for-loop and if-statement to determine which goods belong in each shopping cart. Once identified, I need to display these goods in separate tables corresponding to each customer. Although the ...

Autocomplete suggestions in Sublime Text 2 help users find the right files seamlessly

Do you know if Sublime Text 2 has the capability to automatically suggest directories and files when adding an external script, href, or other elements in a file? I find this feature very helpful when using Webstorm and would be interested in having the ...

Apply a class using [ngClass] based on an HTML condition within the local scope

In the past, I have utilized [ngClass] to assign classes based on the Boolean value of a variable in the JavaScript/TypeScript. However, I am now curious if it is achievable to apply [ngClass] based on a local HTML boolean value instead? For example: < ...

What could be causing bootstrap to suddenly stop working?

Running bootstrap on React and using Storybook to view it has been a smooth process until today. The code that worked flawlessly on Friday is suddenly not working at all. Despite trying it on Jsfiddle and onecompiler, the carousel component copied from the ...