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

116
Vistas
turning overflow-y off with a setTimeout() function

i'm developing a project where the scrollbar needs to be hidden and unable to function for the first 4 seconds on the first render, when the site open (there's a gsap animation). so i set the * {overflow-y: hidden} on css and would like to make it auto again after those seconds with a setTimeout() function, how could i proceed?

about 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

document.querySelector("html").style.overflowY = "hidden";

after 4 secs:

document.querySelector("html").style.overflowY = "auto";

If you don't want to do it this way you could also do this (Codepen):

.class1 {
   overflow-y: hidden;
}

.class2 {
  overflow-y: auto;
}

after 4 seconds just replace class1 with class2 on the node

Third option I give you would be declaring a CSS variable and changing it with js:

:root {
  --scrollbar-var: hidden;
}

html {
 overflow-y: var(--scrollbar-var);
}


let root = document.documentElement;
root.style.setProperty('--scrollbar-var', "auto");

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