Skip to content

Instantly share code, notes, and snippets.

@JTLR
Created February 11, 2014 14:33
Show Gist options
  • Save JTLR/8935901 to your computer and use it in GitHub Desktop.
Save JTLR/8935901 to your computer and use it in GitHub Desktop.
Really simple jquery parallax background
var body;
var backgroundPosition;
var scrollPosition;
var parallaxAmount = 6;
$(document).ready(function () {
body = $('body');
});
$(window).scroll(function () {
scrollPosition = $(window).scrollTop();
bkgPos = -(Math.floor(scrollPosition/parallaxAmount));
body.css('background-position', 'center ' + backgroundPosition + 'px');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment