有没有办法在 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>
最佳答案
就把
-webkit-transition-property: width; -webkit-transition-duration: 500ms;
-moz-transition-property: width; -moz-transition-duration: 500ms;
在 .box 声明中。 你的 JS 没问题。
关于jquery - 无论如何要在 jQuery 事件上向元素添加 css3 过渡动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5589104/