我有一個控件,我想在關鍵幀動畫之後的兩個位置之間轉換。有沒有辦法使用相同的關鍵幀,但相反?另外,有沒有辦法停止動畫,中途倒轉到一開始?如何反轉webkit中的css關鍵幀動畫?
這裏是我現在(我想這兩個關鍵幀結合:
@-webkit-keyframes explode {
0% {
-webkit-transform: scale(1.0) rotate(0deg) translate(0px, 0px);
}
33% {
-webkit-transform: scale(2.0) translate(100px, -150px);
}
67% {
-webkit-transform: scale(2.0) translate(200px, -250px);
}
100% {
-webkit-transform: scale(1.0) translate(-15px, -15px);
}
}
@-webkit-keyframes explodeBack {
0% {
-webkit-transform: scale(1.0) translate(-15px, -15px);
}
67% {
-webkit-transform: scale(2.0) translate(100px, -150px);
}
100% {
-webkit-transform: scale(1.0) rotate(0deg) translate(0px, 0px);
}
}
.leftArrowAnimateForward{
-webkit-animation-name: explode;
-webkit-animation-duration: 3s;
-webkit-animation-timing-function: linear;
-webkit-animation-direction:normal; /* Safari and Chrome */
-webkit-transform: scale(1.0) translate(-15px, -15px);
}
.leftArrowAnimateBackward{
-webkit-animation-name: explodeBack;
-webkit-animation-duration: 3s;
-webkit-animation-timing-function: linear;
-webkit-animation-direction:alternate;
-webkit-transform: scale(1.0) translate(0px, 0px);
}
您確定您需要CSS動畫嗎?你試圖做的事情非常容易與CSS過渡,但關鍵幀版本涉及很多醜陋的js – Duopixel
是的,我虛弱了我的代碼,但實際的關鍵幀要複雜得多。 – QuinnBaetz
嗯......我不認爲你要找的東西可以在CSS3中完成,只能看到「動畫方向」值是正常的和替代的。替補會在正常的方向進行,然後相反,但我認爲你不能完全相反地進行。 –