I'm trying to center the search bar in the footer. After using the solution from: [https://stackoverflow.com/questions/19733447/bootstrap-navbar-with-left-center-and-right-aligned-items][1] I have found that the style for left group of buttons doesn't really work anymore: When I hover over them the css for a:hover doesn't get applied if the cursor is in the middle of the button, but gets applied if the cursor is near the edges. Commenting out the line position: absolute fixes the problem, but then of course the searchbar isn't centered anymore. It is a subtle but annoying problem.
HTML:
<header>
<nav class="navbar navbar-default">
<a class="navbar-brand" href="#">Brand</a>
<ul class="nav navbar-nav pull-left">
<li><a href="#">
<span class="glyphicon glyphicon-home" aria-hidden="true"></span>
</a></li>
<li><a href="#">
<span class="glyphicon glyphicon-comment" aria-hidden="true"></span>
</a></li>
<li><a href="#">
<span class="glyphicon glyphicon-user" aria-hidden="true"></span>
</a></li>
</ul>
<form class="navbar-form" role="search">
<div class="form-group">
<input type="text" class="form-control input-sm" placeholder="Search">
<button type="submit" id="navbar-search-button" class="btn btn-default btn-sm">
<span class="glyphicon glyphicon-search" aria-hidden="true">
</span>
</button>
</div>
</form>
<ul class="nav navbar-nav pull-right">
<li><a href="#">
<span class="glyphicon glyphicon-list" aria-hidden="true"></span>
</a></li>
<li><a href="#">
<span class="glyphicon glyphicon-log-out" aria-hidden="true"></span>
</a></li>
</ul>
</nav>
</header>
CSS:
header {
background-color: #194969;
border: 0;
}
.navbar {
margin: 0 !important;
padding: 0 !important;
height: 3em !important;
border: 0 !important;
border-radius: 0 !important;
background-color: inherit !important;
}
.navbar .navbar-form {
margin-top: 0.75em !important;
}
.navbar > a {
color: #eee !important;
}
.navbar li > a {
margin: 0 !important;
background-color: #194969;
color: #eee !important;
width: 4em;
text-align: center;
}
.navbar li > a:hover {
border-radius: 0 0 0 0 !important;
margin: 0 !important;
color: #194969 !important;
background-color: #eee !important;
height: auto !important;
}
#navbar-search-button {
color: #194969;
}
.navbar-form
{
position: absolute;
width: 100% !important;
left: 0;
text-align: center;
}
The line in question is position:absolute applied to .navbar-form. EDIT: screenshots for clarity: https://i.stack.imgur.com/cI5xu.jpg. [1]: Bootstrap NavBar with left, center or right aligned items