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

188
Vistas
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 Respuestas
Responde la pregunta

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 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