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

214
Views
JS scroll to center with flex reverse

Hi intresting moment which i didnt find in google.

How i can scroll to vertical center with flex reverse ?

Problem in example:

i have temp1.scrollHeight = 1000

but in top position of scroll property temp1.scrollTop return '-940' (not -1000)

i think it calculate how scrollHeight-minus scrollbar element height:

enter image description here

How i can center scroll? like: scrollHeight / 2 - (hight if scrollbar element / 2);

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Find this API in MDN: https://developer.mozilla.org/zh-CN/docs/Web/API/Element/scrollIntoView

Element.scrollIntoView(scrollIntoViewOptions)

params: scrollIntoViewOptions = { block: 'center', } // vertical alignment center

about 4 years ago · Juan Pablo Isaza 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!