由Subnav bar覆盖的Twitter Bootstrap 2顶级导航下拉列表

时间:2012-10-23 04:51:27

标签: css drop-down-menu twitter-bootstrap

我正在使用主导航下拉菜单创建一个Twitter Bootstrap主导航和子导航。问题是我永远无法将下拉菜单显示在子导航上方。这是HTML:

<div class="mainnav navbar navbar-fixed-top navbar-inverse">
    <div class="navbar-inner">
        <div class="container">
            <ul class="nav">
                <li class="dropdown">
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                        Settings
                    </a>
                    <ul class="dropdown-menu">
                        <li><a>test 1</a></li>
                        <li><a>test 2</a></li>
                    </ul>
                </li>
            </ul>
        </div>
    </div>
</div>

<div class="subnav navbar navbar-fixed-top">
    <div class="navbar-inner">
        <div class="container">
            <ul class="nav">
                <li><a>foo</a></li>
                <li><a>bar</a></li>
            </ul>
        </div>
    </div>
</div>

CSS:

.subnav {
    top: 40px;
}

.mainnav .dropdown-menu {
    // how can I show this menu above the subnav???
}

2 个答案:

答案 0 :(得分:2)

没关系,自己想出来。

.subnav {
    top: 40px;
    z-index: 1020; // make z-index smaller than .mainnav
}

JsFiddle Link:

http://jsfiddle.net/j2pCX/1/

答案 1 :(得分:1)

尝试使用z-index:

.subnav {
    position: absolute;
    top: 40px;
    z-index: 10;

}

.mainnav .dropdown-menu {
    position: absolute;
    z-index: 20;
}