Louserhaft schwemer
Louserhaft schwemer

Reputation: 11

Bootstrap 4 collapsed navbar with 2 columns

i want my collapsed navbar to be displayed in 2 columns. I use bootstrap 4.

The fullsize navbar looks like this:

http://prntscr.com/kymuzq

And the collapsed navbar like this:

http://prntscr.com/kymtun

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

Answers (1)

vitta
vitta

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

Related Questions