Jquery CSS动画(抖动)

Jquery CSS动画(抖动),jquery,html,css,Jquery,Html,Css,我正在尝试使用CSS将动画添加到我的HTML中。由于某种原因,它不起作用。非常感谢您的帮助 多谢各位 示例: CSS- .shake { -webkit-animation: shake 1.5s; -moz-animation: shake 1.5s; -ms-animation: shake 1.5s; animation: shake 1.5s; } JS- 您需要添加以下CSS: .shaker:悬停{ /*默认范围显示“内联”不会转换*/ 显示:内联

我正在尝试使用CSS将动画添加到我的HTML中。由于某种原因,它不起作用。非常感谢您的帮助

多谢各位

示例

CSS-

.shake {
    -webkit-animation: shake 1.5s;
    -moz-animation: shake 1.5s;
    -ms-animation: shake 1.5s;
    animation: shake 1.5s;
}
JS-


您需要添加以下CSS:

.shaker:悬停{
/*默认范围显示“内联”不会转换*/
显示:内联块;
动画:无限震撼;
}
@关键帧抖动{
0% {
变换:平移(0px,0px)旋转(0deg);}
2% {
变换:平移(0.5px,-1.5px)旋转(-0.5度);}
4% {
变换:平移(1.5px,-0.5px)旋转(-0.5度);}
6% {
变换:平移(-0.5px,-1.5px)旋转(1.5度);}
8% {
变换:平移(0.5px,-0.5px)旋转(-0.5度);}
10% {
变换:平移(2.5px,2.5px)旋转(-0.5度);}
12% {
变换:平移(2.5px,0.5px)旋转(-0.5度);}
14% {
变换:平移(2.5px,0.5px)旋转(-0.5度);}
16% {
变换:平移(2.5px,-0.5px)旋转(1.5度);}
18% {
变换:平移(2.5px,2.5px)旋转(0.5度);}
20% {
变换:平移(2.5px,2.5px)旋转(0.5度);}
22% {
变换:平移(2.5px,2.5px)旋转(0.5度);}
24% {
变换:平移(1.5px,-0.5px)旋转(-0.5度);}
26% {
变换:平移(1.5px,1.5px)旋转(1.5度);}
28% {
变换:平移(-1.5px,1.5px)旋转(0.5度);}
30% {
变换:平移(2.5px,1.5px)旋转(0.5度);}
32% {
变换:平移(2.5px,2.5px)旋转(1.5度);}
34% {
变换:平移(-1.5px,2.5px)旋转(0.5度);}
36% {
变换:平移(2.5px,-1.5px)旋转(-0.5度);}
38% {
变换:平移(1.5px,0.5px)旋转(-0.5度);}
40% {
变换:平移(-0.5px,-0.5px)旋转(0.5度);}
42% {
变换:平移(-0.5px,-1.5px)旋转(0.5度);}
44% {
变换:平移(-0.5px,1.5px)旋转(1.5度);}
46% {
变换:平移(0.5px,-0.5px)旋转(0.5度);}
48% {
变换:平移(-0.5px,1.5px)旋转(1.5度);}
50% {
变换:平移(2.5px,1.5px)旋转(1.5度);}
52% {
变换:平移(-0.5px,-1.5px)旋转(-0.5度);}
54% {
变换:平移(2.5px,1.5px)旋转(0.5度);}
56% {
变换:平移(-1.5px,2.5px)旋转(0.5度);}
58% {
变换:平移(1.5px,2.5px)旋转(0.5度);}
60% {
变换:平移(1.5px,-1.5px)旋转(-0.5度);}
62% {
变换:平移(-0.5px,0.5px)旋转(0.5度);}
64% {
变换:平移(1.5px,2.5px)旋转(0.5度);}
66% {
变换:平移(-1.5px,-0.5px)旋转(1.5度);}
68% {
变换:平移(0.5px,-1.5px)旋转(1.5度);}
70% {
变换:平移(-0.5px,-0.5px)旋转(0.5度);}
72% {
变换:平移(1.5px,1.5px)旋转(1.5度);}
74% {
变换:平移(1.5px,-0.5px)旋转(1.5度);}
76% {
变换:平移(0.5px,0.5px)旋转(-0.5度);}
78% {
变换:平移(-1.5px,0.5px)旋转(1.5度);}
80% {
变换:平移(-1.5px,0.5px)旋转(1.5度);}
82% {
变换:平移(1.5px,-1.5px)旋转(-0.5度);}
84% {
变换:平移(2.5px,-0.5px)旋转(-0.5度);}
86% {
变换:平移(-0.5px,0.5px)旋转(-0.5度);}
88% {
变换:平移(-1.5px,2.5px)旋转(0.5度);}
90% {
变换:平移(2.5px,0.5px)旋转(1.5度);}
92% {
变换:平移(0.5px,-1.5px)旋转(1.5度);}
94% {
变换:平移(-0.5px,2.5px)旋转(-0.5度);}
96% {
变换:平移(0.5px,1.5px)旋转(0.5度);}
98% {
变换:平移(1.5px,-1.5px)旋转(1.5度);}}
这个应该会震动
试试这个


您必须添加浏览器支持才能在chrome和firefox中使用:

@keyframes thumb {
    0% { transform: scale(1); }
    50% {transform: scale(0.9); }
    100% { transform: scale(1); }
}
@-webkit-keyframes thumb {
    0% { -webkit-transform: scale(1); }
    50% { -webkit-transform: scale(0.9); }
    100% { -webkit-transform: scale(1); }
}

.shake:hover
{
    -webkit-animation-name: thumb;
    animation-name: thumb;
    -webkit-animation-duration: 200ms;
    animation-duration: 200ms;
    -webkit-transform-origin:50% 50%;
    transform-origin:50% 50%;
    -webkit-animation-iteration-count: 2;
    animation-iteration-count: 2;
    -webkit-animation-timing-function: linear;
    animation-timing-function: linear;
}

.shake 
{
    cursor:pointer;
}

似乎您还没有在CSS中定义
shake
动画…
shake
不是默认的动画类型-您需要定义帧。我建议使用一个样式表,它已经为您完成了这项工作,因为这是一项艰巨的任务:您可能需要一个放松类型,例如放松到shake道具,而且,它在所有浏览器中都不工作吗?shake动画在哪里?试试这个演示shake动画/css Lol,这很可爱,但您可以将其减少到4或5个指令,然后将“动画填充模式”设置为“两者”。@Neek感谢您添加代码段。
@keyframes thumb {
    0% { transform: scale(1); }
    50% {transform: scale(0.9); }
    100% { transform: scale(1); }
}

.shake:hover
{
    animation-name: thumb;
    animation-duration: 200ms;
    transform-origin:50% 50%;
    animation-iteration-count: 2;
    animation-timing-function: linear;
}

.shake 
{
    cursor:pointer;
}
@keyframes thumb {
    0% { transform: scale(1); }
    50% {transform: scale(0.9); }
    100% { transform: scale(1); }
}
@-webkit-keyframes thumb {
    0% { -webkit-transform: scale(1); }
    50% { -webkit-transform: scale(0.9); }
    100% { -webkit-transform: scale(1); }
}

.shake:hover
{
    -webkit-animation-name: thumb;
    animation-name: thumb;
    -webkit-animation-duration: 200ms;
    animation-duration: 200ms;
    -webkit-transform-origin:50% 50%;
    transform-origin:50% 50%;
    -webkit-animation-iteration-count: 2;
    animation-iteration-count: 2;
    -webkit-animation-timing-function: linear;
    animation-timing-function: linear;
}

.shake 
{
    cursor:pointer;
}