我一直认为CSS3动画(与CSS3过渡不同)一旦启动,总是完成工作,无论选择器是否不再匹配激活它们的元素.
我今天意识到我可能错了.
在以下示例中,动画由:focus和:active类触发.专注于第一个文本字段:
@-webkit-keyframes pressed {
0%, 100% { transform : scale(1); }
50% { transform : scale(2); }
}
@keyframes pressed {
0%, 100% { transform : scale(1); }
50% { transform : scale(2); }
}
a:focus, a:active {
-webkit-animation : pressed 2s;
animation : pressed 2s;
}
a, input {
border : 1px solid silver;
padding : 5px;
height : 40px;
line-height : 28px;
margin : …Run Code Online (Sandbox Code Playgroud)我有一个动画移动background-position图像与关键帧,这很好.
虽然,当用户点击一个按钮时,我想暂停背景的动画但是有一个过渡,减慢然后停止background-position移动.
我搜索了类似的东西,但我没有找到任何东西,所以我想知道你们中是否有人会知道我怎么能这样做?
谢谢.