【发布时间】:2016-11-08 23:11:25
【问题描述】:
当.move 类仅使用 CSS 添加到 .box 时,如何激活 CSS 动画?动画应该首先平移,当平移完成后,旋转应该从平移结束的地方开始。另外,当.move 类被移除时,如何使动画的结束状态保持 100% 并重置为 0%?
$(".test").click(function(){
$(".box").toggleClass("move")
});
body{
padding: 45px;
}
.test{
margin-top: 15px;
}
.box{
height: 45px;
width: 45px;
background: black;
}
.move{
background: blue;
}
.box{
animation: slide 0.5s, rotate 0.5s;
animation-delay: 0s, 0.5s;
}
@keyframes slide{
100%{
transform: translateX(450px);
}
}
@keyframes rotate{
100%{
transform: rotate(45deg);
}
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="box">
</div>
<button class="test">Toggle</button>
【问题讨论】:
标签: html css css-transitions css-transforms