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

  • Home
  • SEARCH
  • 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 6906409
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:18:22+00:00 2026-05-27T08:18:22+00:00

I’m looking to solve quite a buggy issue I have with a menu. I’ve

  • 0

I’m looking to solve quite a buggy issue I have with a menu. I’ve tagged this with jQuery, too – I’m thinking it can solve the issue faster.

I have a drop-down menu, made in CSS, with inner children. Unfortunately, I don’t know how many children links each parent may have and each of it left floated and block. I can’t edit the CSS each time there’s a new link added to add margin-left.

jsFiddle with the menu: http://jsfiddle.net/guBwZ/1/

What I’m after: I’m trying to display the inner links of Link #2 (also Link #3) right below the Link #2, somehow centered (see below jsFiddle).

jsFiddle with what I’m after: http://jsfiddle.net/6meU8/ (hover on Link #2 and Link #3).

Any help is highly appreciated.
Thank you.

UPATE:

Based on @craniumonempty example, I’ve updated the below jsFiddle with what I was looking for: http://jsfiddle.net/guBwZ/32/

Basically, I’ve moved from display:none to visibility:hidden to measure the width of inner UL and then move it inside the div.center.

Thank you!

  • 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-27T08:18:23+00:00Added an answer on May 27, 2026 at 8:18 am

    first remove the div with the center. I’m not sure it’s even in a place it’s supposed to be either way.

    Next: put “position:relative;” for “#menu ul li” that will line them up.

    Then: remove height and width for “#menu ul li.sub-menu ul”

    http://jsfiddle.net/guBwZ/12/

    Is that kind of what you are looking for?

    Also, if you want examples of multilevel working css menus:

    http://ago.tanfa.co.uk/css/examples/menu/hs7.html

    EDIT: ok, had to leave for a bit. Not sure where you are currently, but here is what I’ve got:

    http://jsfiddle.net/guBwZ/14/

    Not the best code in the world but works. Here is the jquery:

    $(document).ready(function(){
        $("#menu").children("ul").children("li").hover(function(){
            var pos = $(this).position();
            var width = $(this).width();
            $(this).children("div.center").each(function(index){
                $(this).css("display","inline");
                var count = $(this).children("ul").children("li").length;
                var left = (pos.left+width/2)-((width*count)/2);
                if ( left < 0 ) { left = 0; }
                $(this).children("ul").each(function(index2){
                    $(this).css("left",left);
                    left += $(this).width();
                });
            });
        },
        function(){
            $(this).children("div.center").each(function(index){
                $(this).css("display","none");
            });
        });
    });
    

    html:

    <div id="menu">
        <ul>
            <li class="active"><a href="#" title="#">Link #1</a></li>
            <li class="sub-menu">
                <a href="#" title="#">Link #2</a>
                <div class="center">
                    <ul>
                        <li><a href="#" title="#">Link #2-1</a></li>
                        <li><a href="#" title="#">Link #2-2</a></li>
                    </ul>
                </div>
            </li>
            <li class="sub-menu">
                <a href="#" title="#">Link #3</a>
                <div class="center">
                    <ul>
                        <li><a href="#" title="#">Link #3-1</a></li>
                        <li><a href="#" title="#">Link #3-2</a></li>
                    </ul>
                </div>
            </li>
            <li><a href="#" title="#">Link #4</a></li>
            <li><a href="#" title="#">Link #5</a></li>
            <li>
                <a href="#" title="#">Link #6</a>
                <div class="center">
                    <ul>
                        <li><a href="#" title="#">Link #6-1</a></li>
                        <li><a href="#" title="#">Link #6-2</a></li>
                    </ul>
                </div>
            </li>
            <li class="nomarginright"><a href="#" title="#">Link #7</a></li>
        </ul>
    </div>
    

    and css:

    #menu ul {
        list-style-type: none;
        overflow: auto;
        padding: 0;
        margin: 0;
    }
    #menu ul li {
        float: left;
        width: 111px;
    }
    #menu ul li a {
        font:normal 15px/19px Arial, sans-serif;
        color:#9a9b9d;
        display: block;
        padding: 11px 35px 10px 12px;
        text-decoration: none;
        text-transform:uppercase;
    }
    
    #menu ul li.active a {
        background:#FFF;
        color:#000;
    }
    
    #menu ul li:hover a, #menu ul li:hover div{
        background:#191c1f;
    }
    #menu ul li a:hover {
        color:#444;
    }
    
    #menu ul li:hover div{
        display:inline;
    }
    
    #menu ul li.active:hover a {
        background:#FFF;
        color:#000;
    }
    
    #menu ul li div {
        display:none;
        position:absolute;
        height:25px;
        width:100%;
        z-index:99;
        left:0;
    }
    
    
    #menu ul li div ul {
        position:absolute;
        left:30px;
    }
    
    #menu ul li div ul li a {
        padding: 3px 10px 3px 10px;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
Does anyone know how can I replace this 2 symbol below from the string
I have some data like this: 1 2 3 4 5 9 2 6
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and

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.