Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS [Solved] Fixed Menu Bar Re: Fixed Menu Bar

#138629
HenryDurdan
Member

Yep, just fine. jQuery should look something like this:

$(document).ready(function() {
var stickyNavTop = $(‘.nav’).offset().top;

var stickyNav = function(){
var scrollTop = $(window).scrollTop();

if (scrollTop > stickyNavTop) {
$(‘.nav’).addClass(‘sticky’);
} else {
$(‘.nav’).removeClass(‘sticky’);
}
};

stickyNav();

$(window).scroll(function() {
stickyNav();
});
});