一.CSS常见动画属性
(1)
animation 属性是一个简写属性,用于设置六个动画属性:
- animation-name
- animation-duration
- animation-timing-function
- animation-delay
- animation-iteration-count
- animation-direction
(2)transition :过渡效果的 CSS 属性的名称 完成过渡效果需要多少秒或毫秒 速度效果的速度曲线 过渡效果何时开始;
(3)transform: 改变元素的大小、位置;
二.实例
代码:
<!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>动画</title>
<link rel="stylesheet" href="动画.css">
<style>
body {
margin: 0px;
padding: 0px;
}
#Background {
width: 1000px;
height: 1000px;
background-color: aqua;
}
#box {
width: 100px;
height: 100px;
animation: move 4s;
animation-timing-function: linear;
animation-iteration-count: infinite;
animation-direction: alternate;
}
@keyframes move {
0% {
border-radius: 50px;
background-color: rgb(238, 42, 42);
transform: translate(0px, 500px);
}
40% {
width: 100px;
height: 100px;
border-radius: 10px;
background-color: rgb(238, 42, 42);
transform: translate(400px, 500px);
}
45% {
width: 100px;
height: 100px;
background-color: rgb(238, 42, 42);
transform: translate(450px, 500px);
}
50% {
width: 100px;
height: 100px;
background-color: rgb(238, 42, 42);
transform: translate(500px, 500px);
}
55% {
width: 100px;
height: 100px;
background-color: rgb(204, 238, 12);
transform: translate(550px, 500px);
}
60% {
width: 100px;
height: 100px;
border-radius: 10px;
background-color: rgb(204, 238, 12);
transform: translate(600px, 500px);
}
100% {
border-radius: 50px;
background-color: rgb(204, 238, 12);
transform: translate(900px, 500px);
}
}
</style>
</head>
<body>
<div id="Background">
<div id="box"></div>
</div>
</body>
</html>
三.动画效果截图显示