简体   繁体   中英

How can I achieve this background scroll effect?

I really like the way each background section overlaps each other which scrolling down. I have seen it done a lot: here is the link : http://www.soleilnoir.net/believein/

Any ideas how to achieve the similar effect?

Thanks

This effect is called parallax .

Here are some links related to this effect:

You may also like this:

You could achieve that through a combination of watching the scroll offset position and then animating different elements based on that scroll position. You would set an event listener and at certain positions fire functions to animate an element onto the page.

If using jQuery, something like this:

$(document).on("scroll", checkScrollPosition);
function checkScrollPosition() { 
    var scrollPos = $(window).scrollTop();
    switch (scrollPos) {
        case (500):
           doSomething();
           break;
        case (1000):
           doSomethingElse();
           break;
    }
}

function() doSomething {
   // use animate to animate element(s) at 500
}
function() doSomethingElse {
   // use animate to animate element(s) at 1000
}

I'm sure that could be optimized better than that, but that should be enough to get started.

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