Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

168
Vistas
How I can turn my burger menu into a cross?

I would like that when we click on my menu it turns into a cross, I do not understand why it does not work. What would be nice is to be able to launch an animation when another one ends in css

The goal of the animation is that the top and bottom spans disappear and the two small spans in the middle grow and turn 45 degrees.

Thanks for your help, here is my code on codepen below

https://codepen.io/JulienMtau/pen/abOBREK

.icon-menu {
  cursor: pointer;
  width: 30px;
  height: 24px;
  position: relative;

  & > span:first-child {
    transition: width 0.2s;
    position: absolute;
    top: 50%;
    background: black;
    width: 40%;
    height: 1px;
  }

  & > span:last-child {
    transition: width 0.2s, transform 0.2s;
    position: absolute;
    top: 50%;
    transform: translateX(150%);
    background: black;
    width: 40%;
    height: 1px;
  }

  & > span:nth-of-type(2) {
    transition: width 0.2s, margin-left 0.2s;
    position: absolute;
    top: 50%;
    width: 100%;

    &::before,
    &::after {
      content: "";
      position: absolute;
      width: 100%;
      height: 1px;
      background: black;
    }

    &::before {
      transform: translateY(-7px);
    }
    &::after {
      transform: translateY(7px);
    }
  }

  .active:first-of-type {
    animation: burgerToCrossForFirst 1s;
  }

  .active:nth-of-type(2) {
    transition: width 0.2s, margin-left 0.2s;
    width: 0%;
    margin-left: 50%;
  }

  .active:last-of-type {
    animation: burgerToCrossForLast 0.2s;
  }
}

@keyframes burgerToCrossForFirst {
  0% {
    width: 50%;
  }

  50% {
    width: 100%;
  }

  100% {
    transform: rotate(45deg);
  }
}

@keyframes burgerToCrossForLast {
  0% {
    width: 50%;
    transform: translateX(100%);
  }

  50% {
    width: 100%;
    transform: translateX(0%);
  }

  100% {
    transform: translateX(0%) rotate(-45deg);
  }
}
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

   $('.btn').click(function () {
            $(this).toggleClass("click");
        });
    .btn {
        position: absolute;
        top: 15px;
        left: 45px;
        height: 45px;
        width: 45px;
        text-align: center;
        background: #1b1b1b;
        border-radius: 3px;
        cursor: pointer;

    }

    .btn span {
        color: white;
        font-size: 28px;
        line-height: 45px;
    }

    .btn.click span:before {
        content: '\f00d';
        /* cross icon */
    }
<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title></title>
    <link rel="stylesheet" href="style.css">
    <script src="https://code.jquery.com/jquery-3.4.1.js"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css" />
</head>


<body>
    <div class="btn">
        <span class="fas fa-bars"></span>
    </div>


</body>

</html>

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda