简体   繁体   中英

How to change scrolling speed of elements (parallax)

I have recently felt the need for some parallax scrolling on my website, so I have tried stellar.js, which did not work right. So, I came here to ask, how do I make different elements have a different scrolling speed? I want the div element to be slower than the body element. How can I do this?

You can add different steps (speed of scrolling) to each element. Like below

bodyElement.speed= 5;
divElement.speed= 3;

You can try this fiddle. https://jsfiddle.net/krishnakumarm777/44wvewjm/ . Here I have used three canvases with images having different scroll speeds.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM