Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you decrease navbar height in Bootstrap 4?

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?

like image 284
josh_boaz Avatar asked Mar 30 '17 03:03

josh_boaz


People also ask

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 should be the height of navbar?

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.

How do I change the size of the 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.


2 Answers

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

like image 67
Zim Avatar answered Sep 20 '22 00:09

Zim


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.

like image 38
Dush Avatar answered Sep 19 '22 00:09

Dush