Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you decrease navbar height in Bootstrap 3?

I want to make my navbar in BS3 to be of height 20px. How do I do this?

I've tried the following:

.tnav .navbar .container { height: 28px; } 

Did nothing.

.navbar-fixed-top {     height: 25px; /* Whatever you want. */ } 

Appears to be able to increase the size of the bar, but cannot decrease.

What is a good way to do this while preserving the container's alignment, etc.

like image 267
Rolando Avatar asked Oct 24 '13 20:10

Rolando


People also ask

How do I reduce the size of my navigation bar?

To decrease navbar height: add py-0 class to your navbar. Tip: you can combine more classes for individual viewports: e.g., py-3 py-lg-5 classes will make your navbar narrower on mobile devices and larger on laptops and desktops.

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.

What is bootstrap navbar height?

<!-- Links --> 26. <ul class="navbar-nav mr-auto">

How do I reduce the height of the navigation bar in HTML?

To reduce height you need to remove padding on both. This class sets padding-top and padding-bottom to 0. Next set the padding-top and padding-bottom of navbar class to 0. Thats it!


2 Answers

bootstrap had 15px top padding and 15px bottom padding on .navbar-nav > li > a so you need to decrease it by overriding it in your css file and .navbar has min-height:50px; decrease it as much you want.

for example

.navbar-nav > li > a {padding-top:5px !important; padding-bottom:5px !important;} .navbar {min-height:32px !important} 

add these classes to your css and then check.

like image 164
Minder Saini Avatar answered Sep 20 '22 02:09

Minder Saini


Minder Saini's example above almost works, but the .navbar-brand needs to be reduced as well.

A working example (using it on my own site) with Bootstrap 3.3.4:

.navbar-nav > li > a, .navbar-brand {     padding-top:5px !important; padding-bottom:0 !important;     height: 30px; } .navbar {min-height:30px !important;} 

Edit for Mobile... To make this example work on mobile as well, you have to change the styling of the navbar toggle like so

.navbar-toggle {      padding: 0 0;      margin-top: 7px;      margin-bottom: 0; } 
like image 33
felwithe Avatar answered Sep 22 '22 02:09

felwithe