Twitter Bootstrap - full width navbar

Following the example of TB, I have a navbar that is marked up as follows:

<div> <div> <div> <!-- nav bar items here --> </div> </div>
</div>

I'd like this to span the full width of the screen and not have any rounded corners -- similar to static top styling of the navbar.

I can't seem to find how to do this in TB. If there isn't a way, what CSS would I need to override TB and not break responsiveness?

1

11 Answers

Just change the class container to container-fullwidth like this :

<div>
1

Not sure if the navbar-static-top class was available prior to version 2.2.2 but I think you can accomplish your goal with the following:

<div> <div> <ul> <li><a href="#">Test1</a></li> <li><a href="#">Test2</a></li> <li><a href="#">Test3</a></li> <li><a href="#">Test4</a></li> <li><a href="#">Test5</a></li> </ul> </div>
</div>
<div> ...
</div>

I put together a jsFiddle as an example.

Put the navbar out of your container:

<div> <div> <!-- nav bar items here --> </div>
</div>
<div>
</div>

EDIT:

Here is one that I did with responsive navbar. The code fits the document body:

 <div> <div> <div> <!-- .btn-navbar is used as the toggle for collapsed navbar content --> <a> <span></span> <span></span> <span></span> </a> <!-- Be sure to leave the brand out there if you want it shown --> <a href="#">Project name</a> <!-- Everything you want hidden at 940px or less, place within here --> <div> <!-- .nav, .navbar-search, .navbar-form, etc --> <ul> <li><a href="#">Home</a></li> <li></li> <li><a href="#">Link</a></li> <li></li> <li><a href="#">Link</a></li> </ul> <ul> <li><a href="#">Log out</a></li> </ul> </div> </div> </div> </div> <div> <div> <div> </div> </div> </div> <!-- end container --> <script type="text/javascript" src="/assets/js/jquery-1.8.2.min.js"></script> <script type="text/javascript" src="/assets/js/bootstrap.min.js"></script>
7

I'm very late to the party but this answer pulls up top in Google search results.

Bootstrap 3 has an answer for this built in, set your container div in your navbar to container-fluid and it'll fall to screen width.

Like so:

<div> <div> <div> <ul> <li><a href="/">More Stuff</a></li> </ul> </div> </div>
</div>

Put your <nav>element out from the <div class='container-fluid'>. Ex :-

<nav> ......nav content goes here
<nav>
<div> <div> ........ other content goes here </div>
</div>

You need to push the container down the navbar.

Please find my working fiddle here

<header> <h2>Test</h2>
</header>
<div> <div> <ul> <li><a href="#">Test1</a></li> <li><a href="#">Test2</a></li> <li><a href="#">Test3</a></li> <li><a href="#">Test4</a></li> <li><a href="#">Test5</a></li> </ul> </div>
</div>
<div>
</div>
4

Just replace <div> with <div>, which is the container with no margins on both sides.

I think this is the best solution because it avoids some useless overriding and makes use of built-in classes, it's clean.

1

You can override some css

body { padding-left: 0px !important; padding-right: 0px !important;
}
.navbar-inner { border-radius: 0px !important;
}

The !important is needed just in case you link the bootstrap.css after your custom css.

And add your nav html out of a .container

2

To remove the border-radius on the corners add this style to your custom.css file

 .navbar-inner{ -webkit-border-radius: 0; -moz-border-radius: 0; border-radius: 0; }

I know I'm a bit late to the party, but I got around the issue by tweaking the CSS to have the width span 100%, and setting l/r margins to 0px;

#div_id
{ margin-left: 0px; margin-right: 0px; width: 100%;
}

You have to add col-md-12 to your inner-navbar. md is for desktop .you can choose other options from bootstrap's list of options . 12 in col-md-12 is for full width .If you want half-width you can use 6 instead of 12 .for e.g. col-md-6.

Here is the solution to your question

 <div> <div> <div> <!-- nav bar items here --> </div> </div> </div>

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like