I'm utilizing bootstrap 4 with .navbar-nav
.
For a complete live demo, check out the codeply link here:
When the .navbar-nav
switches to mobile collapsed mode at the designated breakpoint,
The following styles are applied, resulting in a nicely stacked list of navbar buttons.
display: flex;
flex-direction: column;
However, I want to control the width of the last two child elements .nav-item
and have them appear side by side.
Is it possible to achieve this using flexbox?
Presently, this is how the navigation looks...
https://i.sstatic.net/lQth1.png
This is how I want the last two items to be displayed...
https://i.sstatic.net/o6lJO.png
I've assigned the last 2 items with the classes .nav-account
, so I just need to add some CSS like this...
.nav-account {
width: 50%;
...
}
To make the last 2 items 50% wide and inline with each other.
Complete code snippet provided below and also available here:
<ul class="navbar-nav flex-lg-grow-1 text-center text-lg-right">
<li class="nav-item active">
<a class="nav-link" href="#">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Products</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">About</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">FAQ's</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Contact</a>
</li>
<li class="nav-item nav-account ml-lg-auto">
<a class="nav-link" href="https://dev.thesweetpeople.co/wp-login.php?redirect_to=https%3A%2F%2Fdev.thesweetpeople.co%2Fprofile">Log in</a>
</li>
<li class="nav-item nav-account">
<a class="nav-link" href="/register"><i class="fas fa-fw fa-user-plus color-sweets"></i> Register</a>
</li>
</ul>