【发布时间】:2017-06-09 18:50:49
【问题描述】:
我正在尝试制作类似于手机振动的效果。这是我目前拥有的:https://codepen.io/anon/pen/jwWwzx
我只是想弄清楚如何添加休息时间,比如振动一秒钟然后暂停一秒钟然后重复。
<div class="phone"><img src="https://i.imgpile.com/nucPMx.png"></div>
.phone {
-webkit-animation: vibrate 0.32s cubic-bezier(.36, .07, .19, .97) infinite;
animation: vibrate 0.32s cubic-bezier(.36, .07, .19, .97) infinite;
-webkit-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0);
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
-webkit-perspective: 300px;
perspective: 300px;
}
@keyframes vibrate {
0.50%, 90% {
-webkit-transform: translate3d(-0.5px, 0, 0);
transform: translate3d(-0.5px, 0, 0);
}
0.50%, 80% {
-webkit-transform: translate3d(0.5px, 0, 0);
transform: translate3d(0.5px, 0, 0);
}
30%, 50%, 70% {
-webkit-transform: translate3d(-0.5px, 0, 0);
transform: translate3d(-0.5px, 0, 0);
}
0.50%, 60% {
-webkit-transform: translate3d(0.5px, 0, 0);
transform: translate3d(0.5px, 0, 0);
}
}
【问题讨论】:
-
我更改了您的示例,使其在每个动画循环结束时暂停一段时间:codepen.io/anon/pen/yXeXwG
标签: css css-animations keyframe