一、动画属性
动画需要声明/创建
@keyframes 动画的名称{动画的运动方式}
二、属性
1.animation-name 动画名字
2.animation-duration 动画的运动持续时间
3.animation-timing-function 动画的运动类型
4.animation-delay 动画的延迟
5.animation-iteration-count 运动的循环次数
6.animation-direction 动画的运动方向
7.animation-play-state 控制动画的运动状态
简写方式
属性:animation
属性值: 动画的名字 动画的时间 动画的延迟 动画的次数 动画的方向
三、示例
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Document</title>
<style>
section {
width: 500px;
height: 500px;
border: 1px solid #000;
margin: 100px auto;
position: relative;
}
div {
width: 100px;
height: 100px;
background: green;
position: absolute;
animation: divMove 3s linear infinite;
}
@keyframes divMove {
0% {
left: 0;
top: 0;
}
25% {
left: 400px;
top: 0;
}
50% {
left: 400px;
top: 400px;
}
75% {
left: 0;
top: 400px;
}
100% {
left: 0;
top: 0;
}
}
section:hover div {
animation-play-state: paused;
}
</style>
</head>
<body>
<section>
<div></div>
</section>
</body>
</html>