Home >Web Front-end >HTML Tutorial >css3中为什么要定位,动画才能动?_html/css_WEB-ITnose
div
{
width:100px;
height:100px;
background:red;
position:relative;
animation:myfirst 5s;
}
@keyframes myfirst
{
0% {background:red; left:0px; top:0px;}
25% {background:yellow; left:200px; top:0px;}
50% {background:blue; left:200px; top:200px;}
75% {background:green; left:0px; top:200px;}
100% {background:red; left:0px; top:0px;}
}
设置了left、top 才能生效
css本来就是只有设置了position,left和top才能生效的