我有一个页面,其中有一个部分,其中有三幅图像从左到右进行动画处理,它们的时间线之间略有重叠。

我试图使动画在垂直滚动200px之后开始。

实现此目标的最佳方法是什么?仅CSS还是我需要使用javascript?

最佳答案

尝试使用jQuery这样的方法。

   /// you probably want to set this dynamically
   var change1 = 200;
    $(document).scroll(function() {

        // you might need to throttle the listener
        if (Math.random() < 0.15) {

            if( $(this).scrollTop() > change1) {
                updateCSS(var);
   }}})


function updateCSS(var) {
    $image1.css({attribute: x);
    $image2.css({attribute: y);
    $image3.css({attribute: z);
}

10-05 20:34
查看更多