Well, I want to achieve this thing: https://i.imgur.com/BDM7JvD.jpg using the Bootstrap 4 Navbar.
How can I centralize the nav-links/items in the middle of the viewport using the flexbox or mr-auto etc utilities. I am trying to avoid a CSS based positioning approach because it may look off on different devices. But sure if a CSS approach promises to be at the same centralized position then why not!
NOTE: some ppl might say to use the justify utilities, the prom is you cant use them as the navbar-brand and the navbar-nav cant be wrapped inside a div. If I do so, the layout messes up.
nav class="navbar navbar-toggleable-md navbar-light bg-custom card-shadow-bottom">
<div class="container">
<button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<a class="navbar-brand" href="#"><img src="img/nav-logo.png" alt="logo" class="nav-logo"></a>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav ml-auto mr-auto">
<li class="nav-item">
<a class="nav-link" href="#">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Disabled</a>
</li>
</ul>
</div>
</div>
</nav>
Use the flexbox utilities to align components the way you want. Here the
justify-content-center
is used to center thenavbar-nav
.More Navbar alignment examples
Update Bootstrap 4.0.0
navbar-toggleable-sm
is nownavbar-expand-md
navbar-inverse
is nownavbar-dark
navbar-fixed-top
is nowfixed-top