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.
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.
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.
<!-- Links --> 26. <ul class="navbar-nav mr-auto">
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!
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.
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; }
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