案例一:
.nav{
/*width: 200px;
height: 200px;
background-color: orange;
border-radius: 50%;*/
animation: yidong infinite 10s alternate;
}
@keyframes yidong{
0%{
width: 200px;
height: 200px;
margin-left: 0%;
border-radius: 50%;
background-color: orange;
}
50%{
width: 200px;
height: 200px;
margin-left: 45%;
border-radius: 0;
background-color: yellow;
}
100%{
width: 200px;
height: 200px;
margin-left: 87%;
background-color: cornflowerblue;
border-radius: 50%;}
}
<body>
<div class="nav" ></div>
<body>
效果图:
案列2:
.nav1{
width: 800px;
height: 500px;
border: 1px solid;
margin: 0 auto;
}
.nav2{
width:100px;
height:100px;
background:red;
position:relative;/*生成相对定位的元素,相对于其正常位置进行定位。*/
-webkit-animation: yi2 infinite 10s alternate;
}
@keyframes yi2{
0%{
background: yellow;
left:0px; top:0px;
}
25%{
background: bisque;
border-radius: 50%;
left:700px;
top: 0;
}
50%{
background: cyan;
border-radius:50% ;
top: 400px;
left: 700px;
}
75%{
background: coral;
border-radius: 0%;
top: 400px;
left: 0px;
}
100%{
background: wheat;
border-radius: 0;
left: 0;
top: 0;
}
}
<body>
<div class="nav1" >
<div class="nav2"></div>
</div>
</body>
效果图: