Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change navbar/container width? Bootstrap 3

The default width for my navbar is too wide 1170px. I would like to reduce it down to 940px - but I want to keep the responsiveness.

I tried to change the container width in CSS and it looks ok with a large browser, but the rest of the page falls apart when viewing for mobile sizes.

Is this the correct property or is there something else?

@media (min-width: 1200px) {   .container {   max-width: 1170px; } 

Here is my navbar code

<div class="navbar navbar-inverse navbar-fixed-top">       <div class="container">         <div class="navbar-header">           <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">             <span class="icon-bar"></span>             <span class="icon-bar"></span>             <span class="icon-bar"></span>            </button>           <a class="navbar-brand" href="#">Site Name</a>         </div>          <div class="collapse navbar-collapse">            <ul class="nav navbar-nav navbar-right">             <li class="active"><a href="#shop">Shop</a></li>             <li><a href="#showcase">Showcase</a></li>             <li><a href="#help">Help</a></li>             <li><a href="#my account">My Account</a></li>             <li><a href="#cart">Cart <span class="glyphicon glyphicon-shopping-cart"></span></a></li>           </ul>         </div><!--/.nav-collapse -->       </div>   </div> 
like image 873
Mark Avatar asked Aug 31 '13 13:08

Mark


People also ask

How do I change the size of my navigation bar?

Change the @navbar-height and @navbar-padding-vertical and you should get it. The navbar itself has no defined width. Cause Bootstrap use the border-box model, the height is set by the highest element inside it. Notice the navbar will have a min-height (set to 50px the default navbar height).

How do you change the width of a navigation bar in HTML?

In order to make the navbar appear 'taller', you would need to set both the height of the ul element itself, as well as the child li . A quick demo has been provided below. I have given the height of the ul element 100px, although this value can be changed to your preference.

How do I change the height of the navigation bar in CSS?

In order to increase the height of the navbar , you have to increase the size of the children > li > a . Keep in mind that the children already have vertical padding of 15px.


2 Answers

I just solved this issue myself. You were on the right track.

@media (min-width: 1200px) {     .container{         max-width: 970px;     } } 

Here we say: On viewports 1200px or larger - set container max-width to 970px. This will overwrite the standard class that currently sets max-width to 1170px for that range.

NOTE: Make sure you include this AFTER the bootstrap.css stuff (everyone has made this little mistake in the past).

Hope this helps.. good luck!

like image 133
Jose Browne Avatar answered Sep 23 '22 11:09

Jose Browne


Container widths will drop down to 940 pixels for viewports less than 992 pixels. If you really don’t want containers larger than 940 pixels wide, then go to the Bootstrap customize page, and set @container-lg-desktop to either @container-desktop or hard-coded 940px.

like image 31
Martin Bean Avatar answered Sep 22 '22 11:09

Martin Bean