2014-05-09 193 views
1

有沒有一種純CSS方式來將div從一個地方移動到另一個地方並停止。我有什麼跳回到原來的地方。使用CSS移動div到一個新的位置,然後在那裏停止

#animate { 
    position: absolute; 
    top: 0px; 
    left: 0px; 
    animation: move 3s ease; 
} 



@keyframes move { 
    from { transform: translateX(0px); } 
    to { transform: translateX(500px); } 
} 

如果我需要JS這個,是否有辦法在動畫結束時調整而不是超時移動它?

回答

0

嘗試增加:

#animate { 
    // other styles... 
    animation-fill-mode: forwards; 
    -webkit-animation-fill-mode: forwards; 
} 

你可以看到這個工作here

貸記到this answer

+0

太棒了!謝謝。 –

相關問題