This question may seem like a duplicate, but it is not. I am specifically asking about Bootstrap version 4.3 and not any earlier versions. The answers I have found so far are either
- not applicable to the current version (useless for updated projects), or
- based on heavily customized Bootstrap (not easily reproducible).
I am currently tasked with customizing Bootstrap, so my question is: How can I center the navbar-brand
link within a Bootstrap 4 navbar
?
Here is a basic example of a navbar
from the Bootstrap 4.3 documentation, which is the latest version as of now:
<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 sources recommend adding the CSS class mx-auto
to the navbar-brand
link, but this does not work in my case.
While I'm at it, does anyone know how to keep the burger menu always visible, so the menu never expands? (This is an additional query, and I will accept responses that do not directly address this as well.)