Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Align Bootstrap Navigation to Center [duplicate]

Tags:

I'm having a problem with bootstrap 3 navigation, i have some content on the left, center and right. it seems there is no option for centering the navigation.

http://jsfiddle.net/29tQt/embedded/result/

I'm trying to get the links titled "center" to be in the center of the page, how can i achieve that ?

<nav class="navbar navbar-default" role="navigation">     <div class="container-fluid">         <div class="navbar-header">             <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1"> <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" href="#">Brand</a>          </div>         <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">             <ul class="nav navbar-nav">                 <li class="active"><a href="#">Center</a>                 </li>                 <li><a href="#">Center</a>                 </li>                 <li><a href="#">Center</a>                 </li>             </ul>             <ul class="nav navbar-nav navbar-right">                 <li><a href="#">Right</a>                 </li>                 <li><a href="#">Right</a>                 </li>             </ul>         </div>     </div> </nav> 
like image 544
trrrrrrm Avatar asked Feb 24 '14 06:02

trrrrrrm


People also ask

How do I align navbar links to the right in Bootstrap?

ml-auto class in Bootstrap can be used to align navbar items to the right. The . ml-auto class automatically aligns elements to the right.

How do I move navigation to center?

You can move the nav elements to the center by putting text-align:center on the ul because the list elements have been set to inline-block which means they can be centred in the same way that you can centre text.


1 Answers

Thank you all for your help, I added this code and it seems it fixed the issue:

.navbar .navbar-nav {     display: inline-block;     float: none; }  .navbar .navbar-collapse {     text-align: center; } 

Source

Center content in responsive bootstrap navbar

like image 164
trrrrrrm Avatar answered Sep 22 '22 21:09

trrrrrrm