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 739599
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T08:25:09+00:00 2026-05-14T08:25:09+00:00

I created a menu in html/css but where I wanted the subitems to be

  • 0

I created a menu in html/css but where I wanted the subitems to be shown on parent item hover. The problem is when I hover on it in IE it only shows it’s subitems when I hover on the text in the menu item, If I hover over the element and not the text the subitems disappear again. So if I hover and want to move my mouse to my submenu the submenu disappears unless I’m fast enough. This is very annoying, does anyone know how I can solve this?

MY menu code is like so:

<ul id="leftnav">
 <li><a>Item1</a></li>
     <ul>
         <li><a href='#'>SubItem1</a></li>
         <li><a href='#'>SubItem2</a></li>
         <li><a href='#'>SubItem3</a></li>
    </ul>
 <li><a>Item2</a></li>
     <ul>
         <li><a href='#'>SubItem1</a></li>
         <li><a href='#'>SubItem2</a></li>
         <li><a href='#'>SubItem3</a></li>
     </ul>
</ul>

The menu should be a left sided menu which shows it’s subitems only on hover, so I used css to achieve this with the following code:

#leftnav, #leftnav ul
{
 padding: 0;
 margin: 0;
}

#leftnav ul li
{
 margin-left: 102px;
 position: relative;
 top: -19px; /*sets the childitems on the same height as the parent item*/
}

#leftnav li
{
 float: left;
 width: 100px;
}

#leftnav ul
{
 position: absolute;
 width: 100px;
 left: -1000px; /*makes it disappear*/
}

#leftnav li:hover ul, #leftnav li.ie_does_hover ul
{
 left: auto;
}

#leftnav a
{
 display: block;
 height: 15px;
 margin-top: 2px;
 margin-bottom: 2px;
}

Since this only works with firefox I also had to insert a javascript to get this to work in IE using code:

<script language="JavaScript">
 sfHover = function()
 { 
  var sfElsE = document.getElementById("leftnav").getElementsByTagName("LI");
  for (var i=0; i<sfElsE.length; i++)
  {
   sfElsE[i].onmouseover=function()
   {
    this.className+=" ie_does_hover";
   }
   sfElsE[i].onmouseout=function()
   {
    this.className=this.className.replace(new RegExp(" ie_does_hover\\b"), "");
   }
  }
 }
 if (window.attachEvent) window.attachEvent("onload", sfHover);
</script> 

Many many many thanks for replies

  • 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-14T08:25:10+00:00Added an answer on May 14, 2026 at 8:25 am

    In your CSS you have:

    #leftnav li:hover ul
    

    Which would mean the rule is applied to ul elements that are children of li elements when that parent li is hovered.

    But in your HTML, you have:

    <li><a>Item2</a></li>
        <ul>
            <li><a href='#'>SubItem1</a></li>
       </ul>
    

    So the sub item ul is not a child of the item ul, so that rule never comes true. You need to make the sub-items nested to the items. Like this:

    <ul id="leftnav">
       <li><a>Item1</a>
           <ul>
               <li><a href='#'>SubItem1</a></li>
               <li><a href='#'>SubItem2</a></li>
               <li><a href='#'>SubItem3</a></li>
          </ul>
       </li>
       <li><a>Item2</a>
           <ul>
                <li><a href='#'>SubItem1</a></li>
                <li><a href='#'>SubItem2</a></li>
                <li><a href='#'>SubItem3</a></li>
          </ul>
       </li>
    </ul>
    

    Notice how I don’t close the list item until after the sub-list.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I created the menu with css but in IE it shows with a problem.
I created a menu item with jquery and CSS but is has a gap
I have created an HTML page which uses simple CSS (no javascript) for menu
Here's my (abstracted) css and HTML: #primary-menu{ text-align: center; margin: 20px 0; } #primary-menu
I have created a menu. It's pretty basic but I got a problem which
How can you add a click event to dynamically created menu item? I thought
I created one accordion menu, issue is I am using .next on li but
I have created a dropdown menu with jquery: here Everything is ok but in
I am trying to create a simple menu using li elements, but it only
I am trying to create a drop down menu using CSS and HTML, it

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.