点击这里查看视频教程
主题 CSS 代码中添加样式
@-webkit-keyframes btn-shake {
from,
to {
-webkit-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0);
}
10%,
30%,
50% {
-webkit-transform: translate3d(-10px, 0, 0);
transform: translate3d(-10px, 0, 0);
}
20%,
40% {
-webkit-transform: translate3d(10px, 0, 0);
transform: translate3d(10px, 0, 0);
}
60% {
transform: translate(0, 0);
}
100% {
transform: translate(0, 0);
}
}
@keyframes btn-shake {
from,
to {
-webkit-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0);
}
10%,
20%,
30% {
-webkit-transform: translate3d(-3px, 0, 0);
transform: translate3d(-3px, 0, 0);
}
15%,
35% {
-webkit-transform: translate3d(3px, 0, 0);
transform: translate3d(3px, 0, 0);
}
40% {
transform: translate(0, 0);
}
100% {
transform: translate(0, 0);
}
}
.btn-shake {
-webkit-animation-name: btn-shake;
animation-name: btn-shake;
-webkit-animation-duration: 1.5s;
animation-duration: 1.5s;
-webkit-animation-delay: 2s;
animation-delay: 2s;
-webkit-animation-fill-mode: both;
animation-fill-mode: both;
-webkit-animation-iteration-count: infinite;
animation-iteration-count: infinite;
}
加购按钮上添加 class
btn-shake