The following might look like a duplicate but isn't. My question concerns the current Bootstrap version 4.3, and no previous version. Existing answers to this question either
- don't work for this version (not useful for up-to-date projects) or
- are based on already heavily customized Bootstrap (not reproducible).
I have the ungrateful task of customizing Bootstrap, so here's my question: How do I center the navbar-brand
link within a Bootstrap 4 (!) navbar
?
Here's a simple navbar
from the Bootstrap 4.3 docs, which is the latest version at the time of this writing:
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<a class="navbar-brand" href="#">Navbar</a>
<button class="navbar-toggler" 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>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto">
<li class="nav-item active">
<a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link disabled" href="#">Disabled</a>
</li>
</ul>
</div>
</nav>
Some of the answers I found while googling suggest to add the CSS class mx-auto
to the navbar-brand
link. This has no effect, though.
Since I'm already here: Does anyone know how to always show the burger menu, i.e., never have the menu expanded? (This is just a side question, I will accept an answer that does not comment on this, too.)