I\'m trying to align the navbar to the right. When I use the .pull-right class it\'s pushing the navbar too much to the right: \"off the grid\".
What am I doing wro
This here worked for me. Putting pull-right
in the div.collapse
doesn't work - it has to be in the un-ordered list class.
<div class="nav-collapse collapse navbar-responsive-collapse">
<ul class="nav navbar-nav pull-right">
The problem arises because in bootstrap-responsive.css the margin-right
is set to 0.
Jsfiddle with a basic mockup See in browser
So you have to provide it with some number to look appropriate, like below:
.navbar .nav.pull-right {
float: right;
margin-right: 98px; /*set margin this way in your custom styesheet*/
}
The html code to create your desired effect can be written in the following way :
<div class="conatiner">
<div class="row-fluid">
<div class="span2 top_logo">
<img width="177" height="60" alt="BETA Team Performance" src="http://placehold.it/177x60">
</div>
<div class="span10">
<div class="navbar navbar-static-top">
<div class="navbar-inner">
<div class="container">
<!-- .btn-navbar is used as the toggle for collapsed navbar content -->
<button data-target=".nav-collapse" data-toggle="collapse" class="btn btn-navbar"
type="button"><strong>MENY <i class="icon-chevron-down icon-white"></i></strong>
</button>
<!-- Everything you want hidden at 940px or less, place within here -->
<div class="nav-collapse collapse ">
<!-- .nav, .navbar-search, .navbar-form, etc -->
<ul class="nav pull-right">
<li class="active"><a href="#">Home</a>
</li>
<li><a href="#">Link</a>
</li>
<li><a href="#">Link</a>
</li>
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
try putting your pull-right
class on the div.collapse
. That may do the trick.
For anyone arriving here who's using Bootstrap v3, just use the included .navbar-right
on the list element:
<div class="collapse navbar-collapse navbar-ex1-collapse">
<ul class="nav navbar-nav navbar-right">
<!-- … -->
</ul>
</div>
If you do want to pull something all the way to the right outside the grid (like select language or social buttons) you can create a simple class and add to the <ul class="nav navbar-nav language">
and style it like so .language {right:50px;position:absolute;}
. Works really well with using the .navbar-brand
as a logo to your far left (from an Art Directors eye, anyways).
In Boostrap 4 you can use ml-auto
to align the menu to the right:
<div class="navbar-nav ml-auto">