ZaitseV
ZaitseV

Reputation: 179

Navbar must appear directly form second div

how can I code the js file to directly put the navbar on the second div? Here is the codepen, it works but on the first load the navbar is sticked on the top of the site; I don't want it.

$(document).ready(function() {
  $(window).scroll(function() {
     if($(window).scrollTop() >= $('#main').outerHeight())
        $('.navbar').removeClass('fixed');
     else
        $('.navbar').addClass('fixed');
  });
});

Upvotes: 0

Views: 41

Answers (1)

Nutshell
Nutshell

Reputation: 8537

Just add .fixed class by default to the nav element and it works :)

Codepen

Upvotes: 2

Related Questions