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

144
Vistas
Different Header on scroll

On my website I have a fixed Bootstrap header and I need this header to completely change its content when I scroll down (not just the css). I thought about doing it with CSS using display:none to hide the whole header and only show the other one when needed but I was wondering if there is another slightly better way.

UPDATE

Here its a piece of my code

HTML

<nav id="nav-estatica" class="navbar navbar-expand-md navbar-dark fixed-top">
MY CONTENT
</nav>
<nav id="nav-fija" class="navbar navbar-expand-md navbar-dark fixed-top">
ANOTHER DIFFERENT CONTENT
</nav>

JS

$(function () {
    $(window).scroll(function () {
      if ($(this).scrollTop() > 200) {
        $('#nav-estatica').fadeOut();
        $('#nav-fija').fadeIn();
      } else {
        $('#nav-fija').fadeOut();
        $('#nav-estatica').fadeIn();
      }
    });
});

The onscroll works fine but the problem is that when refreshing the page both nav's are shown and I only want the fixed-nav to be shown. What am I missing?

UPDATE 2

Solved with CSS

#nav-fija {
    display: none;
}
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I would use window.scrollY to get the current scroll position and render the content depends on the scroll position.

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