Reputation: 11
i want my collapsed navbar to be displayed in 2 columns. I use bootstrap 4.
The fullsize navbar looks like this:
And the collapsed navbar like this:
Anyone knows an easy way to make the collapsed navbar with 2 columns so every list item is shown? So on 5 on the left and 5 on the right side.
Very thankful for any help.
Upvotes: 1
Views: 1957
Reputation: 111
Nav use flex, so you could use it to display the element of the menu as flex elements.
Add to the element with .navbar.nav class the following classes:
.flex-row
The elements are in row and not in column
.flex-wrap
The nav element wrap the children element
Also, you have to use col-6 on every .nav-item, so it splits on two column.
<ul class="navbar-nav mr-auto flex-wrap flex-row">
<li class="nav-item active col-6">
<a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item col-6">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item col-6">
<a class="nav-link disabled" href="#">Disabled</a>
</li>
</ul>
You then should use the proper markup for the different breakpoints
Upvotes: 1