如何将开始和结束位置应用于jquery视差动画

How to apply start and finish positions to jquery parallax animations

本文关键字:应用于 jquery 视差 动画 位置 结束 开始      更新时间:2023-11-11

这是我目前拥有的。

不过,我需要添加一层细节。我想要的是从0-1000px,不透明度没有增加,然后从1000-1500,从0渐变到1。

我该怎么做?

使用这个:(woking jsFiddle)

function EasyPeasyParallax() {
    scrollPos = $(document).scrollTop();
        $('#nav').css({
            'opacity': 0+(Math.min(scrollPos/800,1))
        });
};
$(function(){
    $('body').bind('mousewheel',EasyPeasyParallax);
});

您可以在HTML5浏览器支持中使用css3:

@-webkit-keyframe{ /* for chrome browser */
 0%{
 }
 50%{
 }
 100%{
 }
}
@keyframe{ /*do the same for other browser */
 0%{
 }
 50%{
 }
 100%{
 }
}