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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T20:15:17+00:00 2026-05-15T20:15:17+00:00

I currently have a drop-line horizontal menu using an unordered list with the following

  • 0

I currently have a drop-line horizontal menu using an unordered list with the following HTML markup:

<div class="menu">
  <ul>
    <li><a class="tier1" href="#">Top Link 1</a></li>
    <li>
        <a class="tier1" href="#">Top Link 2</a>
        <ul>
            <li><a href="#">Sub Link 1</a></li>
            <li><a href="#">Sub Link 2</a></li>
            <li><a href="#">Sub Link 3</a></li>
        </ul>
    </li>
    <li><a class="tier1" href="#">Top Link 3</a></li>
  </ul>
</div>

The CSS is far too lengthy to paste in here, but it follows the same structure that I’ve been using for ages here from CSS Menu Maker – the only difference is that for the sub-menu list items, I have them displayed “inline” with their widths set to “auto” and a bit of left and right padding, and every Top Link menu item with a class of “tier1” uses CSS Sprites. The jQuery is where I am having an issue. Ordinarily, this would be the approach to take:

function animateMenu() {
  $('.menu li a.tier1').css({backgroundPosition:'0 -60px'});
  $('.menu li a.tier1').hover(
     function() {
        $(this).stop(true, true).animate({backgroundPosition:'0 0'},{duration:400})
        .next('ul').css({display:'none'}).stop(true, true).delay(200).slideDown(400);
     },
     function() {
        $(this).stop(true, true).animate({backgroundPosition:'0 -60px'},{duration:250})
        .next('ul').stop(true, true).slideUp(400);
     }
  );
}

Whilst this method works, and visually does what I want it to do, the SubMenu obviously slides back up when I mouseout off the Top Link items. My only workaround for this was to break it into two separate functions:

function animateTopMenu() {
    $('.menu li a.tier1').css({backgroundPosition:'0 -60px'});
    $('.menu li a.tier1').hover(
            function() {
                $(this).stop(true, true).animate({backgroundPosition:'0 0'},{duration:400});
            },
            function() {
                $(this).stop(true, true).animate({backgroundPosition:'0 -60px'},{duration:250});
            }
    );
}

function animateSubMenu(){
    $('.menu li').hover(
            function() {
                $(this).find('ul:first').css({display:'none'}).stop(true, true).delay(200).slideDown(400);
            },
            function() {
                $(this).find('ul:first').stop(true, true).slideUp(400);
            }
    );
}

This helps me keep my SubMenu items hover-able when I mouseout off the Top Link, but what I would ideally like to do is retain the hovered background appearance of the Top Links when I hover over the submenu items, and only revert (and animate) to the normal state once the mouse has moved off either the submenu or the top Link itme itself. This is where I am having difficulties. I could add and remove a class with CSS “background-positon: 0 0 !important” but then the animation effect is lost.

I’m sorry for the lengthy question, but just wanted to provide as much as possible to get your help!

Thank you!!
-Shalan

  • 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-15T20:15:17+00:00Added an answer on May 15, 2026 at 8:15 pm

    problem sorted! 😀

    I should’ve figured from the start, but anyway, here is what I had to change:

    1. change the CSS such that the top-level List Item gets the background-image, and not its child hyperlink like how I had it.
    2. change the target element in the Javascript to match with what I did in the CSS.

    It makes perfect sense due to the hierarchy of HTML elements – when you hover over the top-level list item, the nested unordered list is made visible allowing the space (using the term loosely) that the top-level list item occupies to “expand” to include its childrens’ dimensions. So when you hover over any items in the child list, the parent list item is still ‘active’, and the hover function works as it should.

    I will come back to this post in a few days time to update with the working code, should anyone need. For now, I just need to finish the remainder of the project!

    cheers!

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

Sidebar

Related Questions

Currently have a drop down menu that is activated on a hover (from display:none
I currently have a CSS <ul><li> dropdown menu that uses the following code. Unfortunately
I am currently using a CSS menu on PHP includes. I have gotten to
I currently have a drag and drop system for images where you drag a
I have the following code: CurrentDb.Execute DROP TABLE [ & DatabaseName & ].[ &
I'm trying to have both mouseover events and drag-and-drop using JQuery and JQuery UI.
I currently have a dropdown box which contains a list of all of the
I'm currently working on a project at work using the HTML5 Drag and Drop
I currently have a Rails Apps that lets users drag and drop certain elements
I have the following bit of code. I'm trying to dynamically add drop-down options

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.