繁体   English   中英

无论如何将css3过渡动画添加到jQuery事件上的元素

[英]anyway to add css3 transition animation to element on jQuery event

有没有办法在jQuery事件上添加css3动画,例如:

<style>
.box{
width:100px;
height:100px;
bakground-color:#000;
}

.animate{
 width:0px;
 -webkit-transition-property: width; -webkit-transition-duration: 500ms;
 -moz-transition-property: width; -moz-transition-duration: 500ms;
}

<style>

<html>
<div class="box"></div>

<button>click me to animate</button>

$('button').click(function(){
$('.box').addClass('animate');
});

</html>

我认为animo.js可能是你的答案http://labs.bigroomstudios.com/libraries/animo-js (来自http://tympanus.net/codrops/collective/collective-80/

按他们的网站...

“你可以轻松地叠加动画,一个接一个地发射,指定完成动画的回调,或者只是在任何事件或任何你喜欢的时刻发射动画。”

只是把

 -webkit-transition-property: width; -webkit-transition-duration: 500ms;
     -moz-transition-property: width; -moz-transition-duration: 500ms;

在.box声明中。 你的JS很好。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM