Finish burger menu

Asked

Viewed 144 times

0

Guys, I downloaded this menu, I’d like you to help me, I’m learning javascript and I’d like your help. I would like to know how to open and close the menu pq has no and where to put 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
  });
  • See if you get a light, http://www.w3schools.com/howto/howto_js_accordion.asp

  • Possible duplicate: http://answall.com/questions/10962/problema-em-efeito-acordion-simples-em-par%C3%A1graphs/10963#10963

  • 1

    Man, you better clear up your question because it’s hard to figure that one out. It was so formulated that apparently the answer they gave is wrong. Menu "burger" is the one with the three risks () ?

1 answer

0

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

See in demo: https://jsfiddle.net/9oafk4um/

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;
}
  • In my understanding, "burger menu" is the one with the three risks ( ), but it is up to the AP clarify better what is his doubt.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.