Bootstrap 3中的下拉链接水平堆叠

时间:2014-10-23 06:57:07

标签: css twitter-bootstrap twitter-bootstrap-3

我有多个菜单下拉链接。一切正常。但是,当屏幕尺寸是平板电脑时,下拉链接无法正确呈现。当我点击第一个下拉链接“Membership”时,dropdownitem“Manage Users”和下一个下拉链接“Site Configuration”将水平并排呈现,而不是一个在另一个之下。请帮忙。

添加了jsfiddle: - http://jsfiddle.net/u44kj1bk/

<div class="navbar navbar-inverse navbar-fixed-top">
    <div class="container">
        <div class="navbar-header">
            <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
        </div>
        <div class="navbar-collapse collapse">
            <ul class="nav navbar-nav navbar-right">
                <li class="navbar-text">Welcome, User!</li>
            </ul>
            <ul class="nav navbar-nav navbar-right">
                <li class="active"><a href="/">Home</a></li>
                <li class="dropdown">
                    <a class="dropdown-toggle" data-toggle="dropdown" href="#">Membership <span class="caret"></span></a>
                    <ul class="pull-left dropdown-menu">
                        <li><a href="/WebLink">Manage Users</a></li>
                    </ul>
                </li>
                <li class="dropdown">
                    <a class="dropdown-toggle" data-toggle="dropdown" href="#">Site Configuration <span class="caret"></span></a>
                    <ul class="pull-left dropdown-menu">
                        <li><a href="/">Manage Forums</a></li>
                        <li><a href="/WebLink">Manage Web Links</a></li>
                    </ul>
                </li>
                <li class="dropdown">
                    <a class="dropdown-toggle" data-toggle="dropdown" href="#">Themes <span class="caret"></span></a>
                    <ul class="pull-left dropdown-menu">
                        <li><a class="theme-link" datatheme="default" href="#">Day</a></li>
                        <li><a class="theme-link" datatheme="night" href="#">Night</a></li>
                    </ul>
                </li>
            </ul>
        </div>
    </div>
</div>

提前致谢!

1 个答案:

答案 0 :(得分:1)

使用pull-left类会导致列表项浮动到左侧,从而水平堆叠。删除类,这应该工作。

工作示例:http://jsfiddle.net/aqdyfL9h/1/

<div class="navbar navbar-inverse navbar-fixed-top">
        <div class="container">
            <div class="navbar-header">
                <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>                        
            </div>
            <div class="navbar-collapse collapse">
                <ul class="nav navbar-nav navbar-right">
                    <li class="navbar-text">Welcome, User!</li>
                </ul>

<ul class="nav navbar-nav navbar-right">
    <li class="active"><a href="/">Home</a></li>
    <li class="dropdown">
        <a class="dropdown-toggle" data-toggle="dropdown" href="#">Membership <span class="caret"></span></a>
        <ul class="dropdown-menu">
        <li><a href="/WebLink">Manage Users</a></li>
        </ul>
    </li>
    <li class="dropdown"><a class="dropdown-toggle" data-toggle="dropdown" href="#">Site Configuration <span class="caret"></span></a>
        <ul class="dropdown-menu">
            <li><a href="/">Manage Forums</a></li>
            <li><a href="/WebLink">Manage Web Links</a></li>
        </ul>
    </li>
    <li class="dropdown"><a class="dropdown-toggle" data-toggle="dropdown" href="#">Themes <span class="caret"></span></a>
        <ul class="dropdown-menu">
            <li><a class="theme-link" datatheme="default" href="#">Day</a></li>
            <li><a class="theme-link" datatheme="night" href="#">Night</a></li>
        </ul>
    </li>
    </ul>
            </div>            
    </div>
</div>