代码如下
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>关卡七动画(Html5+Css3)</title>
<style>
.d1{
width: 600px;
height: 600px;
background-color: turquoise;
margin:0 auto ;
}
.d2
{
width:100px;
height:100px;
position:relative;
animation:donghua 3s infinite;
animation-direction:alternate;
-webkit-animation:donghua 2s infinite;
-webkit-animation-direction:alternate;
}
@keyframes donghua
{
0% {background:red; border-radius: 50%;left:0; top:250px;}
50% {background: red; left:250px; border-radius: 0;top:250px;}
100% {background:yellow; border-radius: 50%;left: 500px; top:250px;}
}
</style>
</head>
<body>
<div class="d1">
<div class="d2"> </div>
</div>
</body>
</html>