Skip to content

Instantly share code, notes, and snippets.

@shahidulislamus
Created January 28, 2015 16:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shahidulislamus/a4b9337b6eeee3f33f03 to your computer and use it in GitHub Desktop.
Save shahidulislamus/a4b9337b6eeee3f33f03 to your computer and use it in GitHub Desktop.
how to fix menu
add this css
.f-nav{ z-index: 9999; position: fixed; left: 0; top: 0; width: 100%;}
after add jquery you have to add the following javascript code
following "menu" is the div which is fixed when you scroll
jQuery("document").ready(function($){
var nav = $('.menu');
$(window).scroll(function () {
if ($(this).scrollTop() > 136) {
nav.addClass("f-nav");
} else {
nav.removeClass("f-nav");
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment