Skip to content

Instantly share code, notes, and snippets.

@aranw
Created December 9, 2011 15:54
Show Gist options
  • Save aranw/1452068 to your computer and use it in GitHub Desktop.
Save aranw/1452068 to your computer and use it in GitHub Desktop.
Sticky Scrolling
$(document).ready(function(){
function sticky() {
var y = $(window).scrollTop();
if( y > (60) ){
$('.postnav').css({
'position': 'fixed',
'top': '0',
'left': ($(window).width() - $('.container').width())/2 - 10
});
} else {
$('.postnav').removeAttr('style');
}
};
$(window).scroll(sticky);
$(window).resize(sticky);
});
@aranw
Copy link
Author

aranw commented Dec 9, 2011

Credit for this goes to http://twitter.com/#!/_dte

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment