Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6994231
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:51:57+00:00 2026-05-27T19:51:57+00:00

I drop down horizontal menu, which works ok until I mouse leaves it. To

  • 0

I drop down horizontal menu, which works ok until I mouse leaves it. To ilustrate the problem better here are some screenshots:

  1. When I mouse over “Menu item 3”:
    enter image description here
  2. When i mouse out of the ul(Chrome):
    enter image description here
  3. When i mouse out of the ul(Firefox):
    enter image description here

When I mouse out from the ul I need menu to stay as on screenshot 1.
Here is my HTML:

<div  style="position: relative">                
    <nav>
         <ul id="main-menu">
            <li>@Html.ActionLink("Menu item 1", "Index", "InternalHome")</li>
            <li>@Html.ActionLink("Menu item 2", "Index", "TeachingMaterials")
                <ul>
                    <li>@Html.ActionLink("Menu item 2.1", "Index", "TeachingMaterials")</li>
                </ul>
            </li>
            <li>@Html.ActionLink("Menu item 3", "Index", "TeachingMaterials")
                <ul>
                    <li>@Html.ActionLink("Menu item 3.1", "Index", "TeachingMaterials")</li>
                    <li>@Html.ActionLink("Menu item 3.2", "Index", "TeachingMaterials")</li>
                    <li>@Html.ActionLink("Menu item 3.3", "Index", "TeachingMaterials")</li>
                </ul>
            </li>
            <li>@Html.ActionLink("Menu item 4", "Index", "TeachingMaterials")
            <li>@Html.ActionLink("Menu item 5", "Index", "TeachingMaterials")
        </ul>

    </nav>
</div>

CSS:

#main-menu *
{
    margin: 0;
    padding: 0;
}

#main-menu
{
    position: absolute;
    top: 0;
    left: 0;
    margin-left: 100px;
}

#main-menu li
{
    list-style: none;
    float: left;
}
#main-menu li a
{
    margin-right: 5px;
    padding: 2px;
    display: block;
}

#main-menu li ul li a
{
    display: block;
    width: 100%;
}

#main-menu li ul
{
    display: none;
}

#main-menu li:hover ul
{
    position: absolute;
    display: inline;
    left: 0;
    width: 100%;
}

#main-menu li:hover li
{
    float: left;
}

and simple JS to show submenus:

$(document).ready(function () {
var menuLinks = $("#main-menu li");

menuLinks.hover(function () {
    $("#main-menu li ul").hide();
    var menuLinkChildren = $(">ul", $(this));
    if (menuLinkChildren.length > 0) {
        menuLinkChildren.show();
    }
    return false;
}, null);

});

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T19:51:57+00:00Added an answer on May 27, 2026 at 7:51 pm

    The problem is you’re combining CSS hover and jquery hover. Unfortunatly for you CSS wins this battle in modern browsers. Only since CSS3 the :hover on different elements is supported so if you need this to work x-browsers don’t use li:hover.

    Instead of hiding the subMenuItems in CSS you can use that selector to define what happens when they are shown. Hide the submenus in jquery onload.

    The only thing to do then is display the submenu and hide the submenus from siblings.

    example: http://jsfiddle.net/tive/YzwPa/

    CSS

    #main-menu *
    {
        margin: 0;
        padding: 0;
    }
    
    #main-menu
    {
        position: absolute;
        top: 0;
        left: 0;
        margin-left: 100px;
    }
    
    #main-menu li
    {
        list-style: none;
        float: left;
    }
    #main-menu li a
    {
        margin-right: 5px;
        padding: 2px;
        display: block;
    }
    
    #main-menu li ul li a
    {
        display: block;
        width: 100%;
    }
    
    #main-menu li ul
    {
        position: absolute;
        display: inline-block;
        left: 0;
        width: 100%;
    }
    
    #main-menu li ul li
    {
        float: left;
    }
    

    JS

    $(function() {
        var menuLinks = $("#main-menu li");
        menuLinks.find("ul").hide();
        menuLinks.hover(function() {
            $(this).siblings().find("ul").hide();
            $(this).find("ul").show();
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to do drop down horizontal menu in JavaScript. It's works fine
I've got a css-based horizontal drop down menu that works perfectly well, but I'm
I have an horizontal menu, which have a drop down menu on hover: The
I have a drop down menu and it works perfectly on everything except IE6
I am using a Drop Down List for selecting some options. Everything works fine,
http://www.lwis.net/free-css-drop-down-menu/dropdown.simple.horizontal.html Right last item's dropdown goes outside the menu alt text http://shup.com/Shup/374936/110621146-My-Desktop.png I need
http://www.lwis.net/free-css-drop-down-menu/dropdown.simple.horizontal.html in this sample width of dropdown is fixed ul.dropdown ul { margin-top:1px; width:150px;}
I got a reallly simple drop-down menu but got a problem with the submenus
I'm trying to build a horizontal drop down menu with CSS. But the submenu
I created a drop down nav menu purely in css and everything works correctly

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.