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

142
Views
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 answers
Answer question

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