ヘッダーを飛ばそうとしていますが、その後、それをホバーすると、揺れるはずです(両方ともcss3アニメーションで)。それは私が望むように飛んで、揺れますが、要素からマウスを離した後、「-animation-fill-mode: forwards」を設定しても、元の右マージン (フライイン アニメーションの前にあった) に戻ります。 ; chromedevtools を見ると、アニメーションが機能していても、要素が右マージンを変更することはありません..)。これを修正できますか?
また、揺れアニメーションの後に最初のアニメーションが再び発生するのを防ぐ方法はありますか?
フライイン アニメーション:
#name {
margin:40px 2% 40px 0;
-webkit-animation:flyin 1.5s;
-webkit-animation-fill-mode: forwards;
-webkit-animation-timing-function: ease-in-out;
-webkit-animation-delay: 1800ms;
}
@-webkit-keyframes flyin {
from{margin-right: 2%;}
30% {margin-right: 12%;}
50% {margin-right: 9%;}
60% {margin-right: 10%;}
to {margin-right: 10%;}
}
アニメーションを振る:
#name:hover {
**margin-right: 10%; //i also have to set this?! or it starts at 2%**
-webkit-animation:shake 0.7s;
-webkit-animation-fill-mode: forwards;
-webkit-transform-origin:50% 50%;
-webkit-animation-iteration-count: infinite;
-webkit-animation-timing-function: linear;
}
@-webkit-keyframes shake {
0% { -webkit-transform: translate(2px, 1px) rotate(0deg); }
10% { -webkit-transform: translate(-1px, -2px) rotate(-1deg); }
20% { -webkit-transform: translate(-3px, 0px) rotate(1deg); }
30% { -webkit-transform: translate(0px, 2px) rotate(0deg); }
40% { -webkit-transform: translate(1px, -1px) rotate(1deg); }
50% { -webkit-transform: translate(-1px, 2px) rotate(-1deg); }
60% { -webkit-transform: translate(-3px, 1px) rotate(0deg); }
70% { -webkit-transform: translate(2px, 1px) rotate(-1deg); }
80% { -webkit-transform: translate(-1px, -1px) rotate(1deg); }
90% { -webkit-transform: translate(2px, 2px) rotate(0deg); }
100% { -webkit-transform: translate(2px, 1px) rotate(0deg); }
}