That's an awesome parallax effect!
Here is a simple method for creating a parallax effect with a fixed image:
.parallax {
background-attachment: fixed;
}
If you want to use the advanced method like what you saw, follow these steps:
1) Utilize the same CSS as above.
2) Employ the following JavaScript code snippet:
var parallax = document.getElementById('parallax');
window.addEventListener('scroll', function() {
var ypos = window.pageYOffset;
parallax.style.backgroundPositionY = (ypos * -0.5) + "px";
});
Feel free to check out this live example:
var parallax = document.getElementById('parallax');
window.addEventListener('scroll', function() {
var ypos = window.pageYOffset;
parallax.style.backgroundPositionY = (ypos * -0.5) + "px";
});
#parallax {
background-image: url('http://lorempixel.com/400/400/abstract/');
background-attachment: fixed;
min-height: 400px;
}
<div id="parallax"></div>
<div id="content">... (Lorem ipsum text)