效果图
完整代码如下
<!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>CSS动画</title>
<style>
*{
margin: 0px;
padding: 0px;
}
#box1{
width: 1200px;
height: 600px;
background-color: darkturquoise;
}
#box2{
width: 150px;
height: 150px;
background-color:peru;
border-radius: 50%;
position: absolute;
bottom: 250px;
animation-name: move1;
animation-duration: 2s;
animation-direction: alternate;
animation-iteration-count: 2;
}
@keyframes move1{
0%{
transform: translateX(0px);
}
40%{
transform: translateX(500px);
border-radius: 0%;
}
60%{
transform: translateX(600px);
background-color: slateblue;
}
100%{
transform: translateX(1000px);
border-radius: 50%;
background-color: rgb(233, 168, 206);
}
}
</style>
</head>
<body>
<div id="box1"></div>
<div id="box2"> </div>
</body>
</html>