What causes the focus to be lost when hovering over the second item in the sub list

Link to Fiddle: https://jsfiddle.net/n3tzbn4o/3/

Snippet of CSS:

/* Styling for Menu element */
.menu {
  position: relative;
  z-index: 100;
    height: 40px;
    width: 100%;
}

Whenever the cursor hovers over Menu 3 > '2015' > Assesments not submitted, it progresses to the next menu. However, it does not happen in this scenario: https://jsfiddle.net/n3tzbn4o/4/ when the second sub menu does not have another sub menu.

Seeking a resolution for this issue.

Answer №1

Instead of using opacity to toggle the visibility of your menu, consider using display for a more efficient approach. Setting opacity:0; still renders the element, making it respond to hover events, whereas display:none; will not render the element and won't take up space in the DOM.

Modify these 2 styles:

.nav-menu ul {
    position: absolute;
    top: 10px;
    left: 200px;
    /*opacity:0;*/
    display:none;
    ...
}
.nav-menu li:hover > ul { /*opacity:1;*/ display:block; }

Check out the revised 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

How can I achieve a full-width stepper in Bootstrap?

.row { background: #f8f9fa; margin-top: 20px; } .col { border: solid 1px #6c757d; padding: 10px; } <link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/> <link href="https://useloope ...

Align text in the center of a static container

I am facing the challenge of aligning four h4 tags in the center of their respective fixed divs, all set to width: 100% to ensure their background-color: rgba(255, 255, 255, 0.5); covers the entire browser width. Despite trying various combinations of CSS ...

Issue with footer position not remaining at the bottom of the page

Hey there, I've been experiencing some issues with my website's layout. I tried setting a min-height of 1000px on the mainbody to make all the pages the same size, but it's caused a problem with my footer. Now, the footer is positioned in th ...

Utilizing Ajax to dynamically update the content of a div element

As a newcomer to Ajax, I am trying to use xmlhttprequest to dynamically change the content of a div by fetching HTML from different URLs. However, my code doesn't seem to be working as expected. Can someone help me identify what I might be doing wrong ...

Finding the location of an "Apply" button on an Angular HTML page

There is an issue with the positioning of the apply button in the filter bar. Sometimes it displays in the next row instead of alongside the other filters. How can I determine the exact position of this apply button within the HTML page? <div class=&quo ...

What is the best way to use CSS to align an image on a webpage?

I attempted to implement this but I couldn't figure out how to do it or what attribute to use. Can someone assist me with this? Below is my code: <!DOCTYPE html> <html lang="en"> <head> <!--Bootstrap--> <meta name="viewport ...

Shorten a data point in JSON code

I'm currently in the process of developing a stock widget that utilizes JSON to retrieve data from the Yahoo API/YQL console. I am specifically working with values extracted from the key ChangePercentRealtime, however, the values are longer than what ...

Showcase a variety of random images in the navigation bar using Javascript and HTML

In order to create a unique experience for mobile users, I have implemented multiple images for my navigation bar menu icon toggle button. These images are stored in an array and a random image is selected each time the page loads using Math.Random. Howeve ...

Use Jquery to revert the chosen element back to its original base state

I have implemented a select box where selecting a value in the main select box "Domains" will reveal another select box called "Types" such as Diatoms or Flagellates. I have successfully achieved this functionality, but now I am facing an issue with resett ...

When using jQuery to enable contenthover on divs, they will now start a new line instead of

I've been working on achieving a layout similar to this, with the contenthover script in action: Mockup Draft Of Desired Look However, the result I'm getting is different from what I expected, it can be seen here. The images are not aligning co ...

The display/block feature will only function if the div element is contained within a table

I am facing an issue with hiding/showing two div elements alternatively. The code works perfectly when the divs are placed within a table, but fails when they are not in a table due to compatibility issues with Internet Explorer. I prefer not to use a tabl ...

What is the reason for the jQuery plugin not being applied after replacing the page content with an Ajax response?

At the moment, I am utilizing jQuery ajax to dynamically add content to my website. Additionally, I have incorporated the jquery.selectbox-0.6.1.js plugin to enhance the style of select boxes on the page. The plugin successfully styles the select boxes up ...

jquery technique for toggling a single button

My goal is to use jQuery to toggle a button rather than the typical paragraph toggling. I want the button to appear and disappear when clicked, while also increasing the "score" upon each click and decreasing it when the button reappears. Can anyone guide ...

What is the best location to insert CSS in an HTML document?

I tried to customize the CSS on my Blogger blog, but unfortunately, I am unable to access the theme designer. As a result, I attempted to add CSS directly into the code using tags. However, I am having trouble locating the tag within the HTML file. This is ...

Tips on preventing a lone track in Laravel for Server Sent Events

In my Laravel app, I am exploring the use of Server Sent Events. The issue I have encountered is that SSE requires specifying a single URL, like this: var evtSource = new EventSource("sse.php"); However, I want to send events from various parts/controlle ...

impact on the shape of the region's map

Is it possible to add an effect like a border or opacity when hovering over an area in an image map? I've tried using classes and applying hover effects with borders or opacity, but nothing seems to work as expected. Here's my code: <img src= ...

optimal method for displaying HTML strings with components in Vue

My website is a Blog/News site featuring posts that contain HTML content stored in the database. In addition to posts, I also want to include elements like sliders which cannot be generated using v-html. I explored Vue's Render Functions to find a so ...

Are there any known browser compatibility issues with using "./" (dot slash) before HTML files?

Within the realm of shells, using ./ to indicate the current directory is quite common and generally not perceived as risky when specifying a path. On the other hand, in HTML coding, it's typical to omit ./ and instead directly specify the file name. ...

Creating a DIV with vertical scroll-bars exclusively for lengthy paragraphs in HTML: What's the best approach?

I need to display terms and conditions on my website without using a text field or taking up the entire page. Instead, I want to show the text in a specific area with only a vertical scroll bar for users to navigate through the content. Here is the curren ...

results without a table

Currently, I am working on a search page in PHP and I want to display the results in a similar style to the image provided. Could you please advise on how I can achieve this type of design using CSS? I would like it to be a fluid design using percentages, ...