gpt4 book ai didi

javascript - 控制淡入淡出的动画

转载 作者:太空宇宙 更新时间:2023-11-03 19:43:29 24 4
gpt4 key购买 nike

我有以下标记。

<ul id="ticker">
<li><q> Education, then, beyond all other devices of human origin, is the great equalizer of the conditions of men, the balance-wheel of the social machinery </q><cite>Horace Mann</cite></li>
<li><q> The roots of education are bitter, but the fruit is sweet </q><cite>Aristotle</cite></li>
<li><q> Education is what remains after one has forgotten everything he learned in school </q><cite>Albert Einstein</cite></li>
<li><q> Education is the most powerful weapon which you can use to change the world </q><cite>Nelson Mandela</cite></li>
<li><q> Formal education will make you a living; self-education will make you a fortune </q><cite>Jim Rohn</cite></li>
</ul>

和下面的脚本

<script>
function tick()
{
$('#ticker li:first').animate({'opacity':0}, 2000, function () { $(this).appendTo($('#ticker')).css('opacity', 1); });
}
setInterval(function(){ tick () }, 8000);
</script>

问题是文本很好地淡出但重新出现时闪烁​​。我可以通过任何方式使淡入淡出也很平滑。

最佳答案

代替:

$(this).appendTo($('#ticker')).css('opacity', 1);

做类似的事情:

$(this).appendTo($('#ticker')).animate({'opacity' : 1}, 2000);

关于javascript - 控制淡入淡出的动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12611269/

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