【发布时间】:2014-04-10 23:56:25
【问题描述】:
我有一个具有无限 css3 动画的元素,当元素悬停时会更改为另一个无限动画。一切都很好,但有时动画变化太有弹性了,有没有办法在 mouseenter 和 mouseleave 上使动画之间的过渡平滑(也许将元素带到动画之间的初始状态)?两个动画的开始和结束状态是一样的。
@keyframes first-animation {
0% { transform: scale3d(1,1,0);}
50% { transform: scale3d(0.8,0.8,0); }
100% { transform: scale3d(1,1,0); }
};
@keyframes second-animation {
0% { transform: scale3d(1,1,0); }
70% { transform: scale3d(0.7,0.7,0); }
80% { transform: scale3d(0.9,0.9,0); }
100% { transform: scale3d(1,1,0); }
};
div{
animation: first-animation 1.7s ease-in-out infinite;
}
div:hover, div:focus{
animation: second-animation 1.1s ease-in-out infinite;
}
【问题讨论】:
-
你的意思是纯CSS解决方案吗?如果是这样,答案是否定的。如果没有,那么您可以等待
onAnimationEnd事件来切换它 -
为了更精确的动画,我会退出
'ease-in-out'并尝试cubic-beizer()cubic-bezier.com
标签: css animation css-transitions css-animations