I am an amateur at coding and I am trying to code for my own website. How do I create a hamburger icon that changes to gold upon hovering and transforms into an X with dropdown contents after clicking?
The following is my code for a hamburger menu that transforms into an X:
function transformmenubar(x) {
x.classList.toggle("change");
}
.menu-bar{
display: inline-block;
cursor: pointer;
}
.bar1, .bar2, .bar3 {
width: 15px;
height: 2px;
background-color: #000000;
margin: 3px 0;
transition: 0.4s;
}
.change .bar1 {
-webkit-transform: rotate(-45deg) translate(-3px, 3.5px);
transform: rotate(-45deg) translate(-3px, 3.5px);
}
.change .bar2 {opacity: 0;}
.change .bar3 {
-webkit-transform: rotate(45deg) translate(-3px, -4.5px);
transform: rotate(45deg) translate(-3px, -4.5px);
}
<div class="menu-bar" onclick="transformmenubar(this)" =>
<div class="bar1"></div>
<div class="bar2"></div>
<div class="bar3"></div>
</div>
The following is the code for my dropdown content:
.dropdown-content {
height: 100%;
width: 200px;
position: fixed;
z-index: 1;
display: none;
overflow-x: hidden;
margin-top: 50px;
padding-top: 20px;
}
.dropdown-content a {
padding: 6px 8px 6px 16px;
padding-left: 10px;
text-decoration: none;
font-size: 15px;
color: #000000;
display: block;
border: none;
width: 100%;
text-align: left;
cursor: pointer;
outline: none;
font-family: Arial Rounded MT Bold;
}
.dropdown-content a:hover {color: #C5B358;}
.dropdown:hover .dropdown-content {display: block;}
.dropdown:hover {color: #C5B358;}
<div class="dropdown-content">
<a href="#">HOME</a>
<a href="#">SHOP</a>
<a href="#">CATALOGUE</a>
<a href="#">THE COMPANY</a>
<a href="#">CONTACT US</a>
<a href="#">FAQ</a>
</div>
How do I combine my code together to make it work?
Here are the sample pictures of how I want my code to look like: