Finish burger menu

0

Galera, I downloaded this menu, I would like you to help me, I'm learning the javascript and would like the help of you. I would like to know how to open and close the menu because it does not have and where to place the UL LI in html

CSS

.hamburger--slider .hamburger-inner {
  top: 2px; }
  .hamburger--slider .hamburger-inner::before {
    top: 10px;
    transition-property: transform, opacity;
    transition-timing-function: ease;
    transition-duration: 0.2s; }
  .hamburger--slider .hamburger-inner::after {
    top: 20px; }

.hamburger--slider.is-active .hamburger-inner {
  transform: translate3d(0, 10px, 0) rotate(45deg); }
  .hamburger--slider.is-active .hamburger-inner::before {
    transform: rotate(-45deg) translate3d(-5.71429px, -6px, 0);
    opacity: 0; }
  .hamburger--slider.is-active .hamburger-inner::after {
    transform: translate3d(0, -20px, 0) rotate(-90deg); }

HTML

<div class="hamburger hamburger--slider">
  <div class="hamburger-box">
    <div class="hamburger-inner"></div>

  </div>
</div>

JAVASCRIPT

  var hamburger = document.querySelector(".hamburger");
  // On click
  hamburger.addEventListener("click", function() {
    // Toggle class "is-active"
    hamburger.classList.toggle("is-active");
    // Do something else, like open/close menu
  });
    
asked by anonymous 05.01.2017 / 06:59

1 answer

0

As colleague @MagicHat suggested the link, I changed some codes.

See in DEMO: link

See the code:

HTML:

<h2>Cardápio</h2>

<button class="accordion">TRIPLO BACON</button>
<div class="panel">
  <p>Três deliciosos hambúrgueres no pão com gergelim, cheddar em fatias, cebola, temperado ketchup e mostarda.</p>
</div>

<button class="accordion">EXTRA BACON</button>
<div class="panel">
  <p>Pão com gergelim, hambúrguer, duas fatias de bacon, queijo, uma fatia de tomate com maioneses.</p>
</div>

<button class="accordion">HAMBURGER</button>
<div class="panel">
  <p>Pão tostado e quentinho, hambúrguer, cebola e picles com ketchup e mostarda.</p>
</div>

jAVASCRIPT:

<script>
var acc = document.getElementsByClassName("accordion");
var i;

for (i = 0; i < acc.length; i++) {
    acc[i].onclick = function(){
        this.classList.toggle("active");
        this.nextElementSibling.classList.toggle("show");
  }
}
</script>

CSS:

button.accordion {
    background-color: #eee;
    color: #444;
    cursor: pointer;
    padding: 18px;
    width: 100%;
    border: none;
    text-align: left;
    outline: none;
    font-size: 15px;
    transition: 0.4s;
}

button.accordion.active, button.accordion:hover {
    background-color: #ddd; 
}

div.panel {
    padding: 0 18px;
    display: none;
    background-color: white;
}

div.panel.show {
    display: block;
}
    
05.01.2017 / 07:54