HTML

<div class="nav-hamburger">
  <span></span>
  <span></span>
  <span></span>
  <span></span>
</div>

Javascript

document.querySelector('.nav-hamburger').addEventListener('click', function(){
    this.classList.toggle('is-open');
});

CSS

.nav-hamburger {
  width: 30px;
  height: 24px;
  transform: rotate(0deg);
  transition: .5s ease-in-out;
  cursor: pointer;
  position: relative;
  z-index: 2;
}
.nav-hamburger span {
  display: block;
  position: absolute;
  height: 3px;
  width: 100%;
  background: #aaa;
  opacity: 1;
  left: 0;
  transform: rotate(0deg);
  transition: .25s ease-in-out;
}
.nav-hamburger span:nth-child(1) {
  top: 0px;
}
.nav-hamburger span:nth-child(2), .nav-hamburger span:nth-child(3) {
  top: 11px;
}
.nav-hamburger span:nth-child(4) {
  top: 21px;
}
.nav-hamburger.is-open span:nth-child(1) {
  top: 18px;
  width: 0%;
  left: 50%;
}
.nav-hamburger.is-open span:nth-child(2) {
  transform: rotate(45deg);
}