CSS3动画 animation
动画是使元素从一种样式逐渐变化为另一种样式的效果, 可以改变任意多的样式任意多的次数。请用百分比来规定变化发生的时间,或用关键词 "from" 和 "to",等同于 0% 和 100%。0% 是动画的开始,100% 是动画的完成。
1、基本使用
6、animation-play-state暂停或停止
animation-play-state css属性定义一个动画是否运行或者暂停。可以通过查询它来确定动画是否正在运行。另外,它的值可以被设置为暂停和恢复的动画的重放。
/*运行*/
animation-play-state: running;
/*暂停*/
animation-play-state: paused;
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>06-动画animation</title>
<style>
.fa {
width: 500px;
height: 500px;
border: 1px solid;
perspective: 200px;
margin: 0 auto;
}
.sn {
/* transition: all 2s ease-out 1s; */
width: 150px;
height: 150px;
background-color: green;
/* animation: onemove 5s ease-in-out 2s 3 alternate; */
animation: twomove 5s ease-in-out 2s 3 alternate;
}
@keyframes onemove {
from {
width: 150px;
height: 150px;
}
to {
width: 400px;
height: 400px;
}
}
@keyframes twomove {
0% {
/* transform复合值 通过空格隔开 */
transform: translate3d(100px, 100px, 0px) scale(.5);
}
50% {
transform: translate3d(200px, 200px, 0px) scale(2);
}
100% {
transform: translate3d(1, 1, 1 ,45deg) skewX(45deg);
}
}
</style>
</head>
<body>
<div class="fa">
<div class="sn"></div>
</div>
</body>
</html>