2013-12-23 85 views
2

我希望塊從一個點到另一個點。 在小提琴中,您可以看到動畫之後,該塊返回到第一個位置。如何停止我的動畫

我該如何預防?

http://jsfiddle.net/2nT2S/

的CSS

div 
{ 
width:100px; 
height:100px; 
background:black; 
position:relative; 
animation:myfirst 2s; 
-webkit-animation:myfirst 2s; /* Safari and Chrome */ 
} 

@keyframes myfirst 
{ 
from { left:0px; top:0px; } 
to { left:0px; top:200px; } 
} 

@-webkit-keyframes myfirst /* Safari and Chrome */ 
{ 
from { left:0px; top:0px; } 
to { left:0px; top:200px; } 
}  
</style> 

回答

5

只需添加forwardsanimation-fill-mode到動畫:

animation:myfirst 2s forwards; 
-webkit-animation:myfirst 2s forwards; /* Safari and Chrome */ 

jsfiddle