Reputation: 9825
I'm trying to get the search box to be in the center of my Bootstrap navbar. Removing navbar-left seems to destroy the alignment on the navbar. Im going for something like the linkedin.com page. Whats the easiest way to do this?
Heres a link to a JSFiddle of my navbar https://jsfiddle.net/b6pmy9w4/. Thanks in advance for any help.
Html Code:
<nav class="navbar navbar-default" style="border-radius: 0;">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed burger-button" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand jura-font" href="/#!/">COLIGN</a>
</div>
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<form class="navbar-form navbar-left" role="search">
<div class="form-group">
<input type="text" class="form-control" placeholder="Search">
</div>
<!-- <button type="submit" class="btn btn-default">Submit</button> -->
</form>
<ul class="nav navbar-nav navbar-right">
<li><a href="#"><span class="glyphicon glyphicon-comment"></span></a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"><span class="glyphicon glyphicon-user"></span></a>
<ul class="dropdown-menu">
<li><a href="#">View Profile</a></li>
<li><a href="#">Manage Account</a></li>
<li><a href="#">Invite a friend</a></li>
<li role="separator" class="divider"></li>
<li><a href="/auth/signout">Log out</a></li>
</ul>
</li>
</ul>
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container-fluid -->
</nav>
Upvotes: 8
Views: 24430
Reputation: 132
I know this post is old now, but on Bootstrap4 I just added the ml-auto class to the form tag and it worked perfectly:
<form class="form-inline my-2 my-lg-0 ml-auto">
You can also add the col classes to change the size of the form input and the button.
Upvotes: 5
Reputation: 3013
Don't know if it's the best way to do it but
navbar-left
ul
text-align:center
Upvotes: 10