简单的css动画左右移动变化
<!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>Document</title>
</head>
<body>
<div class="box">
<div class="item">
<div class="an">
</div>
</div>
</div>
</body>
<style>
.box{
display: flex;
justify-content: center;
align-items: center;
}
.item{
background-color:cyan;
width:700px;
height: 700px;
border: 2px solid black;
}
.an{
width: 100px;
height: 100px;
animation-name: myfirst;
position: relative;
animation-duration: 6s;
animation-timing-function: linear;
animation-delay: 1s;
animation-iteration-count: infinite;
animation-direction: alternate;
animation-play-state: running;
}
@keyframes myfirst
{
0% {background: red; left:0px; top:0px; border-radius: 0%;}
25% {background: yellow; left:300px; top:0px;border-radius: 25%;}
50% {background: blue; left:600px; top:0px;border-radius: 50%;}
75% {background: green; left:300px; top:0px;border-radius: 25%;}
100% {background: red; left:0px; top:0px;border-radius: 0%;}
}
</style>
</html>
效果实现自行下载实现