I've implemented the solution here which almost solves my problem, however, I need the <ul class="nav">
to be centered between the entire navbar and not just the elements adjacent to it (<a class="brand">
and <p class="navbar-text pull-right">
in my case).
Important: I customized my navbar to be 96px
instead of the default 40px
, and I want the <ul class="nav">
to appear centered and "underneath" the other elements as it will have its own background-color etc.
Here is my code so far:
<div class="navbar navbar-inverse navbar-fixed-top center">
<div class="navbar-inner">
<div class="container-fluid">
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
<a class="brand" href="/home"><img src="http://jayeshcp.files.wordpress.com/2013/03/twitter-bootstrap.jpg" style="width:400px;height:60px;" /></a>
<div class="nav-collapse collapse">
<ul class="nav">
<li><a href="#">One</a></li>
<li><a href="#">Two</a></li>
<li><a href="#">Three</a></li>
<li><a href="#">Four</a></li>
</ul>
<p class="navbar-text pull-right">
<input class="span2" type="text" placeholder="Email">
<input class="span2" type="password" placeholder="Password">
</p>
</div><!--/.nav-collapse -->
</div>
</div>
</div>
Note the extra center
class that I added - that is from the solution that I linked to. It looks like this:
.center.navbar .nav,
.center.navbar .nav > li {
float:none;
display:inline-block;
*display:inline; /* ie7 fix */
*zoom:1; /* hasLayout ie7 trigger */
vertical-align: top;
}
.center .navbar-inner {
text-align:center;
}
.center .dropdown-menu {
text-align: left;
}
How do I center the ul
and give it padding above without breaking everything else in Bootstrap? Would offer more than bounty if there was another currency!
edit: jsfiddle is here (I pasted the whole minified css file (with the customized navbar height) instead of referencing it, sorry. Underneath it are the other customizations.)