Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Parallax scrolling with JavaScript
// Parallax header content
window.onscroll = function emParallax() {
if(window.pageYOffset>1) {
document.getElementById("parallax").style["-webkit-transform"] = "translateY("+(window.pageYOffset/3)+"px)";
} else {
document.getElementById("parallax").style["-webkit-transform"] = "translateY(0px)";
}
}
@daviddarnes

This comment has been minimized.

Copy link
Owner Author

commented Nov 3, 2015

Example CodePen for reference http://codepen.io/daviddarnes/pen/vNajoe

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.