Home  >  Article  >  Web Front-end  >  css3中为什么要定位,动画才能动?_html/css_WEB-ITnose

css3中为什么要定位,动画才能动?_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 11:36:021383browse

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才能生效的

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn