gpt4 book ai didi

jquery - 循环动画

转载 作者:行者123 更新时间:2023-12-01 02:37:00 24 4
gpt4 key购买 nike

<div class="wrapper">
<div class="img">image on background</div>
</div>

.wrapper { position: relative; }
.img { position: absolute; left: 0; top: 0; background: url(image.png); }

.img block 必须是循环动画,它应该从 .wrapper 的左点移动到右点,然后返回。

在返回之前应该有 2 秒的暂停。

我该怎么做?

最佳答案

如果您只想让图像在屏幕上左右移动,您可以使用 animate像这样:

$(function(){
var $image = $('div.img'),
$wrapper = $image.parent(),
delay = 1000,
duration = 4000,
moveRight = function(){
$image.delay(delay).animate({
left: $wrapper.width() - $image.width()
}, {
duration: duration,
complete: moveLeft
});
},
moveLeft = function(){
$image.delay(delay).animate({
left: 0
}, {
duration: duration,
complete: moveRight
});
};

moveRight();
});

关于jquery - 循环动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3949123/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com