im trying to center my navbar with no luck at all.. Anyone here knows how to center it?
Here\'s my code:
FIDDLE
just a little fix to what @Fiskolin has done, if you want it to always be centered you should make sure that the UL will center all text by adding this to it.
ul { text-align:center; }
This one works :- DEMO
<div class="text-center">
<nav class=" navbar navbar-default" role="navigation">
<ul class="nav navbar-nav">
<li><a href="#">HEM</a></li>
<li><a href="#">OM</a></li>
<li><a href="#">VAD ÄR VI?</a></li>
<li><a href="#">TJÄNSTER</a></li>
<li><a href="#">VARFÖR?</a></li>
<li><a href="#">KONTAKT</a></li>
</ul>
</nav>
</div>
CSS
.navbar .nav, .navbar .nav > li {
float:none;
display:inline-block;
}
Try to add css .navbar-nav li {display:inline-block;}
<-- this let all <li>
tags lined up.
Check this FIDDLE to view more details.
Let me know if this was what you're looking for :)
Updated 2017
In Bootstrap 3.x, you can use the nav-justified
class... No custom CSS required:
<nav class="navbar navbar-default" role="navigation">
<div class="container">
<ul class="nav nav-justified">
<li><a href="#">HEM</a></li>
<li><a href="#">OM</a></li>
<li><a href="#">VAD ÄR VI?</a></li>
<li><a href="#">TJÄNSTER</a></li>
<li><a href="#">VARFÖR?</a></li>
<li><a href="#">KONTAKT</a></li>
</ul>
</div>
</nav>
https://www.bootply.com/109568
Bootstrap 4 there is the nav-fill
class...
<nav class="navbar navbar-toggleable-md navbar-light bg-faded">
<div class="container">
<button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbar10">
<span class="navbar-toggler-icon"></span>
</button>
<div class="navbar-collapse collapse" id="navbar10">
<ul class="navbar-nav nav-fill w-100">
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
</ul>
</div>
</div>
</nav>
https://www.bootply.com/bjgAw3F3Ps