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

186
Vistas
How to add transitions to a drop down menu?

I have a drop-down menu that makes text appear when clicked. However, when I add transitions to it, nothing happens. It still just shows up without sliding down. I want the transition to show the text gradually from top to bottom as it appears.

This is the CSS:

.drop-down {
    display: flex;
    flex-direction: column;
    text-align: left;
    transition: height 0.3s ease-in-out;
    transition-delay: 0.1s;
    overflow: hidden;
    position: relative;
}

.menu is the class name for the button clicked that shows this .drop-down text.

I don't know if I used the transition properly.

Should I have used JavaScript instead? And if not what do I need to change?

JavaScript Code:

const menu = document.querySelector('.menu')
const menuContent = document.querySelector('.drop-down')

menu.addEventListener('click', menuClick, false);
menuContent.style.display = 'none'

function menuClick() {
    menuContent.classList.toggle('show');
    if (menuContent.style.display == 'none') {
        menuContent.style.display = 'block'
    } else {
        menuContent.style.display = 'none'
    }
}
about 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

You can do this without javascript.

.drop-down {
    display: flex;
    flex-direction: column;
    text-align: left;
    transition: height 0.3s ease-in-out;
    transition-delay: 0.1s;
    overflow: hidden;
    position: relative;
    opacity:0;
    visibility:hidden;
}
  .menu:hover .drop-down{
   opacity:1;
   visibility:visible;
}

about 4 years ago · Santiago Trujillo 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