Skip to content

Instantly share code, notes, and snippets.

@isramv
Created October 8, 2014 23:03
Show Gist options
  • Save isramv/d4b86144eda6f25a75f7 to your computer and use it in GitHub Desktop.
Save isramv/d4b86144eda6f25a75f7 to your computer and use it in GitHub Desktop.
Sticky menu with jQuery.
.fixedMenu {
position:fixed;
background:white;
z-index:1000;
width:100%;
top:0;
}
elScroll = $('#zone-header-wrapper').offset().top;
$(window).scroll(function(){
var windowTop = $(window).scrollTop();
if(windowTop > elScroll) {
$('#zone-header-wrapper').addClass('fixedMenu').stop();
} else {
$('#zone-header-wrapper').removeClass('fixedMenu').stop();
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment