开发者

Keep jQuery slidedown from pushing page down WITHOUT absolute positioning

I'm trying to create a simple jquery slidedown menu, but it's pushing the page down, and I don't really want开发者_如何学Python that. I can't use absolute positioning.

Here is a jsfiddle of what I have right now.

Any help or suggestions would be greatly appreciated!


Put the navbar in a container with fixed height. This prevents the content from moving.

<div class="navbar_container">
    <ul class="navbar">    
...
    </ul>
</div>

.navbar_container {
    height: 60px;
}

Example jsfiddle

If you want the menu to go over the content you'll have to use absolute positioning though.


Use a containing div:

<div class="navbarWrapper">   
    <ul class="navbar">    
        <li class="link">Username
            <div class="dropdown">
                <a href="#">Profile</a><br />
                <a href="#">Logout</a>
            </div>
        </li>
    </ul>
</div>

... and add to your CSS:

.navbarWrapper 
{
     height: 1em;
}

.navbar 
{
    ...   
    position: absolute;
    ...
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜