Skip to content

Instantly share code, notes, and snippets.

@bbrks
Last active December 22, 2015 03:29
Show Gist options
  • Save bbrks/6410920 to your computer and use it in GitHub Desktop.
Save bbrks/6410920 to your computer and use it in GitHub Desktop.
Super simple parallax scrolling
window.onscroll = function() {
var speed = 4.0;
var ypos = -window.pageYOffset / speed + "px";
var xpos = "50%";
var elems = document.getElementsByClassName('parallax');
for (var i = elems.length - 1; i >= 0; i--) {
elems[i].style.backgroundPosition = xpos +" "+ ypos;
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment