Below is my code for bootstrap 4
<nav class="navbar navbar-collapse navbar-toggleable-md navbar-light bg-faded ">
<div class="collapse navbar-collapse" id="navbarText">
<ul class="navbar-nav mr-auto">
<li class="nav-item">
<a class="nav-link " >
<span class="icon icon18 icon-upload"></span>
Input Data From Prior Month
</a>
</li>
<li class="nav-item">
<a class="nav-link " >
<span class="icon icon18 icon-excel-file"></span>
Export to Excel
</a>
</li>
</ul>
<span class="navbar-text color-blue">
*Data Automatically pulled from sources
</span>
</div>
</nav>
there are various examples given for bootstrap 3 here How do you decrease navbar height in Bootstrap 3? but none of them seem to work for bootstrap 4, can anyone help with this one?
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.
Personally I feel most comfortable using a navbar height of 64px. It is enough height to accommodate a logo, and there is room enough to use text in combination with symbols.
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.
Decreasing the Navbar height is easier in Bootstrap 4 using the spacing utils. The height of the navbar comes from padding in the Navbar contents.
Just use py-0
in the nav-link
and navbar-text
..
<nav class="navbar navbar-collapse navbar-toggleable-md navbar-light bg-faded "> <div class="collapse navbar-collapse" id="navbarText"> <ul class="navbar-nav mr-auto"> <li class="nav-item"> <a class="nav-link py-0"> <span class="icon icon18 icon-upload"></span> Input Data From Prior Month </a> </li> <li class="nav-item"> <a class="nav-link py-0"> <span class="icon icon18 icon-excel-file"></span> Export to Excel </a> </li> </ul> <span class="navbar-text py-0 color-blue"> *Data Automatically pulled from sources </span> </div> </nav>
The py-0
class sets padding-top:0;padding-bottom:0
on the items.
Bootstrap 4 Navbar Shrink Height
If anyone like changing CSS to get the same result, try this method. In my case I have just changed the .navbar
min-height
and the links font-size
and it decreased the navbar.
For example:
.navbar{
min-height:12px;
}
.navbar a {
font-size: 11.2px;
}
And this also worked for increasing the navbar height.
This also helps to change the navbar size when scrolling down the browser.
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