Jquery – A logo fixed position is positioned relative to the browser window.

$(function() {
var offset = $(“#logo”).offset();
var topPadding = 15;
$(window).scroll(function() {
if ($(window).scrollTop() > offset.top) {
$(“#logo”).stop().animate({
marginTop: $(window).scrollTop() – offset.top + topPadding
});
} else {
$(“#logo”).stop().animate({
marginTop: 0
});
};
});
});

Advertisements