bootstrap 3 - how do I place the brand in the center of the navbar?
I am using Bootstrap 3. I would like a navbar with only the brand in it. No other links or anything else. And I want the brand to be in the center. How can I accomplish this? The following css doesn't work:
.navbar-brand {
text-align: center;
}
css:
.navbar-header {
float: left;
padding: 15px;
text-align: center;
width: 100%;
}
.navbar-brand {float:none;}
html:
<nav class="navbar navbar-default" role="navigation">
<div class="navbar-header">
<a class="navbar-brand" href="#">Brand</a>
</div>
</nav>
Use these classes: navbar-brand mx-auto
All other solutions overcomplicate the matter.
Another option is to use nav-justified
..
<nav class="navbar navbar-default" role="navigation">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div class="navbar-collapse collapse">
<ul class="nav nav-justified">
<li><a href="#" class="navbar-brand">Brand</a></li>
</ul>
</div>
</nav>
CSS
.navbar-brand {
float:none;
}
Bootply
Alternate example
If you have no other links, then there is no use for navbar-header....
HTML:
<nav class="navbar navbar-inverse navbar-static-top">
<div class="container">
<a class="navbar-brand text-center center-block" href="#">Navbar Brand</a>
.....
</nav>
CSS:
.navbar-brand {
float: none;
}
However, if you do want other links here's a very effective approach that allows that: https://stackoverflow.com/a/34149840/3123861