从导航栏品牌打开下拉菜单

时间:2012-09-07 14:09:42

标签: css twitter-bootstrap

每当我点击导航栏的品牌时,我想打开一个下拉菜单(使用Twitter Bootstrap),所以我尝试了这段代码:

<div class="navbar navbar-fixed-top">
<div class="navbar-inner">
<div class="tabbable">
    <div class="dropdown">
    <a id="drop1" class="dropdown-toggle" data-toggle="dropdown" href="#menu">
        <div class="brand">Brand</div>
    </a>
    <ul class="dropdown-menu" role="menu" aria-labelledby="drop1">
        <li><a href="#">Action</a></li>
    </ul>
    </div>
<ul class="nav">
    <li>
        <a href="#" data-toggle="tab">Item</a>
    </li>
</ul>
</div>
</div>
</div>

结果:当我点击它时,会出现菜单,但它 over 品牌,而不是 下的。如何解决?

实施例

1 个答案:

答案 0 :(得分:8)

要正确呈现下拉列表,您的品牌必须是.nav li元素。所以只需将.brand类添加到标准下拉列表中。

<div class="navbar navbar-fixed-top">
    <div class="navbar-inner">
        <div class="tabbable">
            <ul class="nav">
                <li class="dropdown">
                    <a id="drop1" class="dropdown-toggle brand" data-toggle="dropdown" href="#menu">
                        Brand
                    </a>
                    <ul class="dropdown-menu" role="menu" aria-labelledby="drop1">
                        <li><a href="#">Action</a></li>
                    </ul>
                </li>
                <li>
                    <a href="#" data-toggle="tab">Item</a>
                </li>
            </ul>
        </div>
    </div>
</div>

这将打破您的品牌定位,但您可以通过这个简单的CSS粉丝修复它:

.navbar .brand {
    margin-left: 10px; /* This value could be different for another layout */
}