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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:19:05+00:00 2026-06-13T11:19:05+00:00

I am trying to create a sticky accordion menu, where the background scrolls depending

  • 0

I am trying to create a sticky accordion menu, where the background scrolls depending on the button clicked, but the menu remains at its place. Since its sticky, I am using position:fixed. Here’s the HTML :

<div id="nav">
<ul>
    <li><a id="home" class="menu-link" href="#section0"><img src="images/home.png" /></a></li>
    <li><a id="aboutus" class="menu-link" href="#section1"><img src="images/aboutus.png" /></a>
        <ul class="submenu">
        <li><a id="submenu1" class="menu-link" href="submenu1.php"><img src="images/submenu1.jpg" /></a></li>
        <li><a id="submenu2" class="menu-link" href="submenu2.php"><img src="images/submenu2.jpg" /></a></li>
        </ul>
    </li>
    <li><a id="dances" class="menu-link" href="#section2"><img src="images/dances.png" /></a></li>
    <li><a id="packages" class="menu-link" href="#section3"><img src="images/packages.png" /></a>
        <ul class="submenu">
        <li><a id="submenu3" class="menu-link" href="submenu3.php"><img    src="images/submenu3.jpg" /></a></li>
        <li><a id="submenu4" class="menu-link" href="submenu4.php"><img src="images/submenu4.jpg" /></a></li>
        </ul>
    </li>
    <li><a id="gallery" class="menu-link" href="#section4"><img src="images/gallery_menu.png" /></a>
        <ul class="submenu">
        <li><a id="submenu5" class="menu-link" href="submenu5.php"><img src="images/submenu5.jpg" /></a></li>
        <li><a id="submenu6" class="menu-link" href="submenu6.php"><img src="images/submenu6.jpg" /></a></li>
        </ul>
    </ul>
</div>

I am looking for an accordion (like this), and I am not able to work with slideUP, slideToggle etc (probably coz of position:fixed). So I tried to calculate the number of children the clicked menu-item had and shift all the rest of the menu below it by a appropriate amount. THe code is this :

$('#nav ul li a').bind('click',function(event){
    var no_of_child=$(this).parent('li').children('ul').index()+1;
    var clicked_position=$(this).position();
    if(no_of_child>0){
        var top_rel=60*no_of_child;
        $(this).parent('li').nextAll().children('a').animate({
        top: "+="+top_rel,
    });

The menu is shifting fine, but I am stuck at getting it to go back to its original position when a different menu-item is clicked.

Note : I think I “have” to use position:fixed for the menu, since my background continuously scrolls up and down.

  • 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-06-13T11:19:06+00:00Added an answer on June 13, 2026 at 11:19 am

    Wrap the <div id="nav"> in a div that is fixed, and change the nav div to relative positioning.

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

Sidebar

Related Questions

Trying to create a black line in my view to separate text blocks but
Trying to create a new Dedicated Cache Role in Windows Azure but get the
Trying to create a background-image slideshow and am getting this error... This is the
I'm trying to create a menu that will stick at the bottom of the
Hi im trying to create an sticky footer that will show in every activity
I trying to create reply to sticky note annotation using iText, does anyone know
I am trying to create a bottom aligned, fluid width sticky footer that contains
I'm trying to make a script to create four terminals, each running its own
With the jquery.waypoints plugin you can easily create sticky elements. Its sticky elements demo
I'm trying to create a floating header. content area and then a sticky footer.

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.