Skip to content

Instantly share code, notes, and snippets.

@AleeRojas
Created July 29, 2013 18:56
Show Gist options
  • Save AleeRojas/6106736 to your computer and use it in GitHub Desktop.
Save AleeRojas/6106736 to your computer and use it in GitHub Desktop.
Leave menu bar fixed on top when scrolled
/* Dynamic top menu positioning
*
*/
var num = 300; //number of pixels before modifying styles
$(window).bind('scroll', function () {
if ($(window).scrollTop() > num) {
$('.navbar').addClass('navbar-fixed-top');
} else {
$('.navbar').removeClass('navbar-fixed-top');
}
});
//http://jsfiddle.net/adamb/F4BmP/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment