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

128
Vistas
How can I detect which element is currently at 20vh from the top?


I hope everyone is ok!

I'm trying to achieve something simple, yet I don't know how to do it exactly. I'm trying to do a fixed table of content, which highlights the active section.

The content:

<div class="content">
    <div id="step-1">
        ...
    </div>
    <div id="step-2">
        ...
    </div>
    <div id="step-3">
        ...
    </div>
</div>

The sidebar:

<nav>
    <a href="#step-1">
        <span>Step 1</span>
    </a>
    <a href="#step-2">
        <span>Step 2</span>
    </a>
    <a href="#step-3">
        <span>Step 3</span>
    </a>
</nav>

As you can see, nothing too fancy. The problem is that I tried to do it with IntersectionObserver and intersectionRatio, and it gives the .active class to every .content > div that enters the screen.

What I would like, is a script in Javascript (or jQuery) that gives the .active class to THE current .content > div element that reach the limit of (for example) 20vh from the top of the screen.

Thanks a lot, I hope I'm clear enough.

about 4 years ago · Santiago Trujillo
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