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>
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).
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.
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.
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!
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
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With