Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

117
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda