Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap navbar toggler icon (hamburger) size

Just wondering if there is any way to resize Bootstrap's navbar toggler icon?

I'm using the .navbar-dark theme as a template, here are the dimensions:

.navbar-dark {
  background-color: #111 !important;
}

.navbar {
  background-image: url("/images/Harris_Logo_Small2.svg");
  background-position: center;
  background-repeat: no-repeat;
  height: 25px;
  padding: 0px;
  margin: 3px;  
}

.navbar-nav {
  background-color: #111111;
  border-color: #111111;
}

And here is the corresponding CSS:

.navbar .navbar-toggle {
  border-color: #ff0000;
}

.navbar .navbar-toggle:hover,
.navbar .navbar-toggle:focus {
  background-color: #ff0000;
}

button.navbar-toggler {
  background-color: #111111;
  height: 25px;
  width: 25px;
}

button.navbar-toggler .icon {
  background-color: #111;
}

.navbar-default .navbar-toggle .icon-bar{
  background-color: #111;
}

.navbar .navbar-toggle .navbar-toggler-icon {
  color: #ecf0f1;
  height: 20px !important;
  width: 20px !important;
}

As you can (hopefully) see, the toggler icon is far too large for the dimensions I've chosen for the navbar height. Any help is greatly appreciated.

like image 519
Sloan Bell Avatar asked Oct 18 '17 06:10

Sloan Bell


2 Answers

In bootstrap 3:

You can override .navbar-toggle .icon-bar bootstrap class. check below snippet for reference.

.navbar-dark {
  background-color: #111 !important;
}
.navbar-toggle .icon-bar{
  width: 50px !important;
  height:3px !important;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<nav class="navbar navbar-inverse navbar-dark">
  <div class="container-fluid">
    <div class="navbar-header">
      <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>                        
      </button>
      <a class="navbar-brand" href="#">WebSiteName</a>
    </div>
    <div class="collapse navbar-collapse" id="myNavbar">
      <ul class="nav navbar-nav">
        <li class="active"><a href="#">Home</a></li>
        <li class="dropdown">
          <a href="#">Page 1</a>
        </li>
        <li><a href="#">Page 2</a></li>
        <li><a href="#">Page 3</a></li>
      </ul>
    </div>
  </div>
  </

In bootstrap 4:

.navbar-inverse .navbar-toggler-icon{
  padding: 30px !important;
}

Note: In bootstrap 4 you cannot increase height/width independently. It will be affecting both height and width when using padding.

like image 185
RaJesh RiJo Avatar answered Nov 15 '22 02:11

RaJesh RiJo


In Bootstrap 4.1. You would most likely use the "navbar-toggler-icon" class. In witch case, if you want to just resize the bars, you would just be resize the font-size of it:

.navbar-toggler-icon{
    font-size: 0.8em;
}

If you want to resize the button around it, just target the "navbar-toggler" and mess with the padding/margins as you desire:

.navbar-toggler{
    padding-top: 2%;
    padding-bottom: 2%;
}
like image 43
CoverEye Avatar answered Nov 15 '22 03:11

CoverEye