Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Finally a simple parallax script I like
$(window).scroll(function(e){
parallax();
});
function parallax() {
var scrolled = $(window).scrollTop();
//81% is the original top position of the element,
// which could be made into a variable onload instead
$('#foo').css('top', 'calc(81% - ' + (scrolled * .2) + 'px)');
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.