Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

115
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!