/**
* This snippet assumes the element you want to parallax scroll has a background-image and class of `background-active`
*/
window.addEventListener('scroll', function (e) {
document.getElementsByClassName('background-active')[0].style.backgroundPositionY = parseInt(document.body.scrollTop * -0.2) + 'px';
});
The simplest, easiest way to achieve parallax with no unnecessary plugins or code.
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.