I am trying to create a side bar with an animated menu button. I found an example online of the button I imagined and am trying to use it correctly but cant seem to get it where I want on my page. Why do the three divs that make up the animated button appear to the right of the trapezoid and not within it?
#trap {
position: absolute;
left: 0px;
top; 0px;
height: 38px;
width: 40px;
border-left: 40px solid black;
border-bottom: 5px solid transparent;
border-top: 5px solid transparent;
margin-left: 0;
transition: 0.5s;
}
.container {
display: inline-block;
cursor: pointer;
}
.bar1, .bar2, .bar3 {
width: 35px;
height: 5px;
background-color: #A4A4A4;
margin: 6px 0;
transition: 0.4s;
}
.change .bar1 {
-webkit-transform: rotate(-45deg) translate(-9px, 6px) ;
transform: rotate(-45deg) translate(-9px, 6px) ;
}
.change .bar2 {opacity: 0;}
.change .bar3 {
-webkit-transform: rotate(45deg) translate(-8px, -8px) ;
transform: rotate(45deg) translate(-8px, -8px) ;
}
<div id="trap" class="container" onclick="toggleNav(this)">
<div class="bar1"></div>
<div class="bar2"></div>
<div class="bar3"></div>
</div>