1

i am trying to implement jquery's toggle method to make a dropdown menu, it actually works just fine, the only problem is that the dropdown menu pushed its parent container and it seems like it add some height to it, it kinda hard for me to say this but let me show some of my html and css

Html:

<div id="header_container">
    <h1>This is Header</h1>
    <div id="personal_menu">
        <ul>
            <li>
            Welcome back user!
            </li>
            <li class="main_link">
                <a href="#">My links</a>
                <ul class="sublink" style="display: block;">
                    <li><a href="#">link 1</a></li>
                    <li><a href="#">link 2</a></li>
                    <li><a href="#">link 3</a></li>
                    <li><a href="#">link 4</a></li>
                </ul>
            </li>
            <li>
            <a href="#">Logout</a>    </li>
        </ul>
    </div>
</div>

CSS

#header_container{
    width:960px;
    overflow:auto;
    padding: 10px 15px;
    margin: 0 auto;
}
#header_container{
    background:#BED308;
    height:218px;
    -moz-border-radius: 0 0  40px 40px;
    border-radius: 0 0  40px 40px;
}
#personal_menu{
    overflow: auto;
    position: relative;
    right: 0;
    top: 135px;
    width: 100%;            
}
        #personal_menu ul, #main_menu ul{ list-style-type:none;}
        #personal_menu ul{
            float: right;
            margin-top: 5px;
        }
            #personal_menu li{
                float: left;
                text-align: center;
            }
            #personal_menu li{
                margin: 0;
                padding: 3px 5px;
            }
                #personal_menu li a{
                    color: #fff;
                    text-decoration:none;
                }
                #personal_menu li a:hover{
                    text-decoration:underline;
                }
                #personal_menu ul li ul {
                    display: none;
                    position: absolute;
                    width: 160px;
                    border: 1px solid #ccc;
                    padding: 10px 0;
                    z-index: 1000;
                }

and jquery:

$(function() {  
    $(".main_link").click(function(){
        $(".sublink").toggle();
    });
});

so when i click the main_link class, the toggled sublink stays inside the header container making my header scrollable, i have tried to put some z-index rule to my sublink because i figure that it need to be on top of everything else but still no luck, please help.

Thanks

2 Answers 2

1

Try to delete overflow:auto. If you have undesired scroll, the problem must be here.

Sign up to request clarification or add additional context in comments.

5 Comments

i have removed over flow auto on every container that has the rule, still no luck
please, give a link for your menu
@littlechad: I took your code to jsfiddle, removed the overflow:auto as @Webars said, your overflow seems to be gone and your menu now flows out of the header_container. jsfiddle.net/robx/xAGsG
hmm, alright, i will tested this out, will get back at you guys will an update, thanks
thanks guys, it turn out to be that there are other container that causing the toggle doesn't work the one wraps the header_container has an overflow:auto in it, and yes this solve the problem thanks a lot
1

Which browser are you using?

Beware that IE7.0 has a z-index bug which causes something like your case, More info here: IE7 Z-Index Layering Issues

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.