I've been trying to design a navbar using Bootstrap, with the 'navbar-brand' on the left, centering the navbar items in the middle, and having two items on the right. Initially, I attempted to create it from scratch but struggled to make it responsive enough.
Eventually, I came across this solution on Bootply, which closely resembles what I want in terms of responsiveness and navbar collapse functionality. However, I would like to switch the positions of the navbar-brand and left items; with the brand aligned to the left and the left items centered, while keeping the right items in place.
[ Navbar-Brand Home | About | Contact | Address Right, Right]
What is the most efficient way to achieve this layout?
Here is the code snippet:
.navbar-brand {
position: absolute;
width: 100%;
left: 0;
text-align: center;
margin:0 auto;
}
.navbar-toggle {
z-index:3;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<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>
<a class="navbar-brand" href="#">Brand</a>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav navbar-left">
<li><a href="#">Left</a></li>
<li><a href="#about">Left</a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li><a href="#about">Right</a></li>
<li><a href="#contact">Right</a></li>
</ul>
</div>
</nav>