Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change icon-bar (☰) color in bootstrap

I want to change ☰ color.

HTML:

<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#menu">   <span class="sr-only">Toggle menu navigation</span>   <span class="icon-bar"></span>   <span class="icon-bar"></span>   <span class="icon-bar"></span> </button> 

I tried various things (look bellow) but nothing works.

CSS:

.icon-bar {   color: black;   border-color: black;   background-color: black; } 
like image 285
a1204773 Avatar asked Dec 12 '13 10:12

a1204773


People also ask

How do I change the color of my burger in bootstrap 5?

The hamburger toggler color is controlled by the two inbuilt classes used for changing the color of the content in the navigation bar: . navbar-light: This class is used to set the color of the navigation bar content to dark.

How do I change the toggle button color in bootstrap?

In Bootstrap 4, the background color of the toggle switch is blue. This color can be changed by manipulating the custom-control-input class.


1 Answers

The reason your CSS isn't working is because of specificity. The Bootstrap selector has a higher specificity than yours, so your style is completely ignored.

Bootstrap styles this with the selector: .navbar-default .navbar-toggle .icon-bar. This selector has a B specificity value of 3, whereas yours only has a B specificity value of 1.

Therefore, to override this, simply use the same selector in your CSS (assuming your CSS is included after Bootstrap's):

.navbar-default .navbar-toggle .icon-bar {     background-color: black; } 
like image 152
James Donnelly Avatar answered Sep 23 '22 19:09

James Donnelly