效果图:
实现从左侧到右侧,图形从圆-正方形-圆,并且颜色变化的过程:
<!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>
</head>
<style>
body{
margin: 0px;
padding: 0px;
background-color: aqua; width: 1400px;height: 1000px;
}
.cc{
width:100px;
height:100px;
background-color: palevioletred;
border-radius: 50%;
position:absolute;
margin-top: 5px;
margin-left: 0px;
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(600px, 500px);
}
45% {
width: 100px;
height: 100px;
background-color: rgb(238, 42, 42);
transform: translate(650px, 500px);
}
50% {
width: 100px;
height: 100px;
background-color: rgb(238, 42, 42);
transform: translate(700px, 500px);
}
55% {
width: 100px;
height: 100px;
background-color: rgb(204, 238, 12);
transform: translate(750px, 500px);
}
60% {
width: 100px;
height: 100px;
border-radius: 10px;
background-color: rgb(204, 238, 12);
transform: translate(800px, 500px);
}
100% {
border-radius: 50px;
background-color: rgb(204, 238, 12);
transform: translate(1400px, 500px);
}
}
</style>
<body>
<div class="cc"></div>
</body>
</html>