简体   繁体   中英

Two Bootstrap nav menus at the same time

I like to know if its possible to have two nav's at the same time.

Here is a JSFiddle with the bootstrap test with only the collapse JavaScript for the navbar. Both menus get expanded at the same time, is there a way to prevent that?

You can, all you have to do is differentiate the data-target attribute with a unique class or id for your dropdown menus like so:

For your first dropdown

<a class="btn btn-navbar" data-toggle="collapse" data-target="#first">

For your second dropdown:

<a class="btn btn-navbar" data-toggle="collapse" data-target="#second">

Then you can add that unique id to your nav collapse container:

First

<div id="first" class="nav-collapse"> ... </div>

Second

<div id="second" class="nav-collapse"> ... </div>

Demo: http://jsfiddle.net/F2tYu/3/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM