Skip to content

Instantly share code, notes, and snippets.

@leafnode
Created March 13, 2014 19:06
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 leafnode/9534757 to your computer and use it in GitHub Desktop.
Save leafnode/9534757 to your computer and use it in GitHub Desktop.
$(document).ready( function() {
$(window).scroll(function() {
var top = $('#content').offset().top;
var _top = $('#content').position().top;
var scroll = $(window).scrollTop();
if (scroll > top) {
var data = {
'position': 'fixed',
'top': '20px'
};
} else {
var data = {
'position': 'absolute',
'top': _top
};
}
$('#float-ad').css(data);
$('#float-ad-right').css(data);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment