我希望在同一个导航栏行上有两个可折叠的菜单。左侧菜单将显示站点的主菜单,而右侧菜单将显示“用户菜单”。
<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="#user-menu">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#main-menu">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">My Site</a>
</div>
<span id="main-menu" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li class="active"><a href="#">Home</a></li>
<li><a href="about">About</a></li>
<li><a href="members">Members</a></li>
<li><a href="forum">Forum</a></li>
<li><a href="mow">Register</a></li>
<li class="dropdown">
<a href="Products" class="dropdown-toggle" data-toggle="dropdown">Products <b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="cars">Factions</a></li>
<li><a href="software">Tanks</a></li>
<li><a href="food">Infantry</a></li>
</ul>
</li>
</ul>
<form id="sys-login_form" target="passwordIframe" method="POST" action="blank.php" class="navbar-form navbar-right">
<span id="sys-login_status"></span>
<div class="form-group">
<input type="text" placeholder="Username" class="form-control" name="username" id="sys-login-username" title="Username" data-active="0">
</div>
<div class="form-group">
<input type="password" placeholder="Password" class="form-control" name="password" id="sys-login-password" title="Password" data-active="0">
</div>
<input name="remember_login" id="sys-login-remember" type="checkbox" checked="checked" value="forever" title="Remember">
<button type="button" class="btn btn-success" title="Login" name="login_btn" id="sys-login_btn" data-in_use="0">Go</button>
</form>
<iframe id="sys-passwordIframe" name="passwordIframe" style="display:none"></iframe>
</span>
<span id="user-menu" class="navbar-collapse collapse">
<ul class="nav navbar-nav navbar-right">
<li class="dropdown">
<a href="profile/fred" id="sys-username_box" class="dropdown-toggle" data-toggle="dropdown">Fred <b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="account/settings">Settings</a></li>
<li><a data-in_use="0" href="account/logout">Logout</a></li>
</ul>
</li>
<li class="dropdown"><a href="about">Mail</a></li>
<li><a href="about">Bookmarks</a></li>
</ul>";
</span>
</div></div>
它在移动视图中运行良好,即显示 2 个折叠菜单,但在正常模式或全屏模式下,右侧的用户菜单被推到主菜单下方的新行。
一个完整的例子可以在这里看到:http: //bootply.com/79056