I am trying to set the background color of my hamburger menu to black. However, I am facing an issue with the CSS :after and :before classes. When I hover over them, they change color one by one instead of all three lines changing together. How can I make all 3 lines in the menu hover in black simultaneously?
https://i.sstatic.net/hwash.png
I attempted the following solution, but it only changes the color one by one:
.BurgerMenu:hover:after,
.BurgerMenu:hover,
.BurgerMenu:hover:before{
background: #000;
}
.BurgerMenu {
position: relative;
left: 6px;
top: 26px;
height: 2px;
width: 25px;
background: #979797;
}
.BurgerMenu:before {
transition: all 0.25s;
content: "";
position: absolute;
left: 0;
top: -0.5em;
height: 2px;
width: 25px;
background: #979797;
}
.BurgerMenu:after {
position: absolute;
content: "";
left: 0;
top: 0.5em;
height: 2px;
width: 25px;
background: #979797;
transition: all 0.25s;
}
.BurgerMenu:hover:after,
.BurgerMenu:hover,
.BurgerMenu:hover:before{
background: #000;
}
<nav id="nav-storage" class="Navigation">
<section class="Navigation--collapsed">
<div class="BurgerMenu"></div>
</section>
</nav>
Check out the JSFiddle here