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

191
Views
Scroll to an element that has position sticky

So I have an element that resides at the bottom of my list using:

position: sticky;
bottom: 0;

And I am using scrollIntoView(true) to scroll to it. There is two problems though.

  1. It scrolls first to a position where the sticky element in in its original position. Not stickied to the bottom. Then you have to fire the scrollIntoView once again so it scrolls the element to the top.

  2. ScrollIntoView scrolls the whole window too even though the element is inside a scrollable container.

I can't find a solution for either problem. My goal is to have a sticky element and be able to align it to the top when clicking it. I am using Angular but I don't really think that matters.

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

0

The solution was:

  scrollTo(container: HTMLUListElement, header: HTMLLIElement) {
    container.scrollTo(0, header.offsetTop);
    container.scrollTo(0, header.offsetTop);
  }

It's important that you neither use smooth scrolling in the scrollTo function or scroll-behavior: "smooth" in CSS.

And don't forget to add position: relative to the container.

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!