前端怎么实现div盒子在下方缓慢跳动
可以使用CSS3的动画效果来实现div盒子在下方缓慢跳动。
首先,需要定义一个带有动画效果的CSS类,例如:
.bounce {
animation-name: bounce;
animation-duration: 1s;
animation-fill-mode: both;
}
@keyframes bounce {
0%, 20%, 50%, 80%, 100% {
transform: translateY(0);
}
40% {
transform: translateY(20px);
}
60% {
transform: translateY(10px);
}
}
然后,在需要跳动的div盒子上添加该类即可:
<div class="box bounce"></div>
这样,这个div盒子就会在下方缓慢跳动起来了。可以调整animation-duration属性来改变动画的速度,也可以调整keyframes中的transform属性来改变跳动的幅度和频率。
原文地址: http://www.cveoy.top/t/topic/g1yG 著作权归作者所有。请勿转载和采集!