优雅地动画一堆divs

编程入门 行业动态 更新时间:2024-10-14 02:20:42
本文介绍了优雅地动画一堆divs的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试实现一个不错的动画,但是我有点卡住使用CSS只是为了达到我想要的效果。目前我正在使用animate.css为新元素设置动画,但旧元素不会优雅地移动,因为我没有进一步的动画。

I am trying to achieve a nice animation, however I am a bit stuck using CSS only to achieve the effect that I want. Currently I am using animate.css to animate new elements in, but the old element dont move gracefully, since I have no further animation.

这是 jsfiddle/tcq8kuy6/1/ 说明了我动画的当前状态。

Here is a jsfiddle/tcq8kuy6/1/ illustrating the current state of my animation.

setInterval(function(){ var newbox = "<div class='child animated bounceInDown'></div>" $('.container').prepend(newbox); }, 2000);

推荐答案

小提琴

为了做到这一点,我做了几件事情: -

In order to make this work I did a couple of things:-

1 CSS

.child { width: 40px; height: 40px; display: block; //inline block results in jerkiness when inserting items margin:2px; //added margin to compensate for inline-block becoming block. border: 1px solid #AAAAAA; }

JS

2 JS

setTimeout(function(){ var newbox = "<div class='child animated bounceInDown'></div>" $(newbox).prependTo('.container').hide().slideDown(500);//notice that I prepend to the container, then hide the 'newbox' and then slide it down -> this gives the desired effect. }, 2000);

希望有帮助。

更多推荐

优雅地动画一堆divs

本文发布于:2023-11-12 19:59:01,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1582396.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:优雅   动画   divs

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!