I am trying to make the button shake without hovering on it. When I am removing the "hover" element, the button doesn't shake at all. What should I change in the code to make it work?
.first_button:hover {
animation: shake 0.82s cubic-bezier(.36, .07, .19, .97) both;
transform: translate3d(0, 0, 0);
backface-visibility: hidden;
perspective: 1000px;
}
#keyframes shake {
10%,
90% {
transform: translate3d(-1px, 0, 0);
}
20%,
80% {
transform: translate3d(2px, 0, 0);
}
30%,
50%,
70% {
transform: translate3d(-4px, 0, 0);
}
40%,
60% {
transform: translate3d(4px, 0, 0);
}
}
<button class="first_button">Button</button>
Use the infinite prop for your animation.
More info on animation syntax
.first_button {
animation: shake 0.82s cubic-bezier(.36, .07, .19, .97) both infinite;
transform: translate3d(0, 0, 0);
backface-visibility: hidden;
perspective: 1000px;
}
#keyframes shake {
10%,
90% {
transform: translate3d(-1px, 0, 0);
}
20%,
80% {
transform: translate3d(2px, 0, 0);
}
30%,
50%,
70% {
transform: translate3d(-4px, 0, 0);
}
40%,
60% {
transform: translate3d(4px, 0, 0);
}
}
<button class="first_button">Button</button>
i have a little problem in my css animation, the code works in google chrome, ie9+ and safari but not in firefox.
I tried to use -moz-, but nothing happened. This animation have five images, but in mozilla only showed the first image.
Code:
.anima {
will-change: transform;
margin: 0 auto;
max-width: 436px;
width: 100%;
height: 400px;
-webkit-animation-name: effect; /* Chrome, Safari, Opera */
-webkit-animation-duration: 14s; /* Chrome, Safari, Opera */
animation-name: effect;
animation-duration: 14s;
animation-iteration-count: infinite;
animation-timing-function: ease-in-out;
background: url("http://miceone.com.br/imagens/fazer-26fdbd895c.svg") 0% 0% / contain no-repeat;
}
/* Chrome, Safari, Opera */
#-webkit-keyframes effect {
0% {transform: rotate3d(0, 0, 0, 0deg); margin: 0 auto!important;}
5% {background: url("http://miceone.com.br/imagens/fazer-26fdbd895c.svg") 0% 0% / contain no-repeat; transform: rotate3d(0, 0, 0, 0deg); margin: 0 auto!important;}
10% {transform: rotate3d(1, 0, 0, 100deg);}
15% {background: url("http://miceone.com.br/imagens/evoluir-fb7c0c3ecb.svg") 0% 0% / contain no-repeat; transform: rotate3d(0, 0, 0, 0deg); margin: 0 auto!important;}
25% {background: url("http://miceone.com.br/imagens/evoluir-fb7c0c3ecb.svg") 0% 0% / contain no-repeat; transform: rotate3d(0, 0, 0, 0deg); margin: 0 auto!important;}
30% {transform: rotate3d(1, 0, 0, 100deg);}
35% {background: url("http://miceone.com.br/imagens/crescer-a364c2e9fb.svg") 0% 0% / contain no-repeat; transform: rotate3d(0, 0, 0, 0deg); margin: 0 auto!important;}
45% {background: url("http://miceone.com.br/imagens/crescer-a364c2e9fb.svg") 0% 0% / contain no-repeat; transform: rotate3d(0, 0, 0, 0deg); margin: 0 auto!important;}
50% {transform: rotate3d(1, 0, 0, 100deg);}
55% {background: url("http://miceone.com.br/imagens/acontecer-dedf63a20d.svg") 0% 0% / contain no-repeat;transform: rotate3d(0, 0, 0, 0deg); margin: 0 auto!important;}
65% {background: url("http://miceone.com.br/imagens/acontecer-dedf63a20d.svg") 0% 0% / contain no-repeat; transform: rotate3d(0, 0, 0, 0deg); margin: 0 auto!important;}
70% {transform: rotate3d(1, 0, 0, 100deg);}
75% {background: url("http://miceone.com.br/imagens/acreditar-55f9efcefd.svg") 0% 0% / contain no-repeat; transform: rotate3d(0, 0, 0, 0deg); margin: 0 auto!important;}
85% {background: url("http://miceone.com.br/imagens/acreditar-55f9efcefd.svg") 0% 0% / contain no-repeat; transform: rotate3d(0, 0, 0, 0deg); margin: 0 auto!important;}
90% {transform: rotate3d(1, 0, 0, 100deg);}
100% {background: url("http://miceone.com.br/imagens/fazer-26fdbd895c.svg") 0% 0% / contain no-repeat; transform: rotate3d(0, 0, 0, 0deg); margin: 0 auto!important;}
}
/* Standard syntax */
#keyframes effect {
0% {transform: rotate3d(0, 0, 0, 0deg); margin: 0 auto!important;}
5% {background: url("http://miceone.com.br/imagens/fazer-26fdbd895c.svg") 0% 0% / contain no-repeat; transform: rotate3d(0, 0, 0, 0deg); margin: 0 auto!important;}
10% {transform: rotate3d(1, 0, 0, 100deg);}
15% {background: url("http://miceone.com.br/imagens/evoluir-fb7c0c3ecb.svg") 0% 0% / contain no-repeat; transform: rotate3d(0, 0, 0, 0deg); margin: 0 auto!important;}
25% {background: url("http://miceone.com.br/imagens/evoluir-fb7c0c3ecb.svg") 0% 0% / contain no-repeat; transform: rotate3d(0, 0, 0, 0deg); margin: 0 auto!important;}
30% {transform: rotate3d(1, 0, 0, 100deg);}
35% {background: url("http://miceone.com.br/imagens/crescer-a364c2e9fb.svg") 0% 0% / contain no-repeat; transform: rotate3d(0, 0, 0, 0deg); margin: 0 auto!important;}
45% {background: url("http://miceone.com.br/imagens/crescer-a364c2e9fb.svg") 0% 0% / contain no-repeat; transform: rotate3d(0, 0, 0, 0deg); margin: 0 auto!important;}
50% {transform: rotate3d(1, 0, 0, 100deg);}
55% {background: url("http://miceone.com.br/imagens/acontecer-dedf63a20d.svg") 0% 0% / contain no-repeat;transform: rotate3d(0, 0, 0, 0deg); margin: 0 auto!important;}
65% {background: url("http://miceone.com.br/imagens/acontecer-dedf63a20d.svg") 0% 0% / contain no-repeat; transform: rotate3d(0, 0, 0, 0deg); margin: 0 auto!important;}
70% {transform: rotate3d(1, 0, 0, 100deg);}
75% {background: url("http://miceone.com.br/imagens/acreditar-55f9efcefd.svg") 0% 0% / contain no-repeat; transform: rotate3d(0, 0, 0, 0deg); margin: 0 auto!important;}
85% {background: url("http://miceone.com.br/imagens/acreditar-55f9efcefd.svg") 0% 0% / contain no-repeat; transform: rotate3d(0, 0, 0, 0deg); margin: 0 auto!important;}
90% {transform: rotate3d(1, 0, 0, 100deg);}
100% {background: url("http://miceone.com.br/imagens/fazer-26fdbd895c.svg") 0% 0% / contain no-repeat; transform: rotate3d(0, 0, 0, 0deg); margin: 0 auto!important;}
}
<div class="anima"></div>
I posted this code in CodePen also.
Thanks!
I solved the problem!
In firefox, it's not possible animate the property background
Sorry for the lack of information, my english isn't so good :/
For more informations, see this oficial mozilla page below!
https://bugzilla.mozilla.org/show_bug.cgi?id=1036761
Code below:
.anima-box, .anima-box div {
margin: 0 auto!important;
max-width: 436px;
width: 100%;
height: 400px;
}
.anima-box div {
will-change: transform, opacity;
position: absolute;
left: 0;
top: 0;
-webkit-animation-duration: 14s; /* Chrome, Safari, Opera */
animation-duration: 14s;
animation-iteration-count: infinite;
animation-timing-function: ease-in-out;
}
.anima-fazer {
-webkit-animation-name: effect-fazer; /* Chrome, Safari, Opera */
animation-name: effect-fazer;
background: url("http://miceone.com.br/imagens/fazer-26fdbd895c.svg") 0% 0% / contain no-repeat;
opacity: 1.0;
}
.anima-evoluir {
-webkit-animation-name: effect-evoluir; /* Chrome, Safari, Opera */
animation-name: effect-evoluir;
background: url("http://miceone.com.br/imagens/evoluir-fb7c0c3ecb.svg") 0% 0% / contain no-repeat;
opacity: 0.0;
}
.anima-crescer {
-webkit-animation-name: effect-crescer; /* Chrome, Safari, Opera */
animation-name: effect-crescer;
background: url("http://miceone.com.br/imagens/crescer-a364c2e9fb.svg") 0% 0% / contain no-repeat;
opacity: 0.0;
}
.anima-acontecer {
-webkit-animation-name: effect-acontecer; /* Chrome, Safari, Opera */
animation-name: effect-acontecer;
background: url("http://miceone.com.br/imagens/acontecer-dedf63a20d.svg") 0% 0% / contain no-repeat;
opacity: 0.0;
}
.anima-acreditar {
-webkit-animation-name: effect-acreditar; /* Chrome, Safari, Opera */
animation-name: effect-acreditar;
background: url("http://miceone.com.br/imagens/acreditar-55f9efcefd.svg") 0% 0% / contain no-repeat;
opacity: 0.0;
}
#-webkit-keyframes effect-fazer {
0% {transform: rotate3d(0, 0, 0, 0deg); opacity: 1.0;}
5% {transform: rotate3d(0, 0, 0, 0deg); opacity: 1.0;}
10% {transform: rotate3d(1, 0, 0, 100deg); opacity: 0.0;}
90% {transform: rotate3d(1, 0, 0, 100deg); opacity: 0.0;}
95% {transform: rotate3d(0, 0, 0, 0deg); opacity: 1.0;}
100% {transform: rotate3d(0, 0, 0, 0deg); opacity: 1.0;}
}
#keyframes effect-fazer {
0% {transform: rotate3d(0, 0, 0, 0deg); opacity: 1.0;}
5% {transform: rotate3d(0, 0, 0, 0deg); opacity: 1.0;}
10% {transform: rotate3d(1, 0, 0, 100deg); opacity: 0.0;}
90% {transform: rotate3d(1, 0, 0, 100deg); opacity: 0.0;}
95% {transform: rotate3d(0, 0, 0, 0deg); opacity: 1.0;}
100% {transform: rotate3d(0, 0, 0, 0deg); opacity: 1.0;}
}
#-webkit-keyframes effect-evoluir {
0% {transform: rotate3d(0, 0, 0, 0deg); opacity: 0.0;}
10% {transform: rotate3d(1, 0, 0, 100deg); opacity: 0.0;}
15% {transform: rotate3d(0, 0, 0, 0deg); opacity: 1.0;}
25% {transform: rotate3d(0, 0, 0, 0deg); opacity: 1.0;}
30% {transform: rotate3d(1, 0, 0, 100deg); opacity: 0.0;}
100% {transform: rotate3d(0, 0, 0, 0deg); opacity: 0.0;}
}
#keyframes effect-evoluir {
0% {transform: rotate3d(0, 0, 0, 0deg); opacity: 0.0;}
10% {transform: rotate3d(1, 0, 0, 100deg); opacity: 0.0;}
15% {transform: rotate3d(0, 0, 0, 0deg); opacity: 1.0;}
25% {transform: rotate3d(0, 0, 0, 0deg); opacity: 1.0;}
30% {transform: rotate3d(1, 0, 0, 100deg); opacity: 0.0;}
100% {transform: rotate3d(0, 0, 0, 0deg); opacity: 0.0;}
}
#-webkit-keyframes effect-crescer {
0% {transform: rotate3d(0, 0, 0, 0deg); opacity: 0.0;}
30% {transform: rotate3d(1, 0, 0, 100deg); opacity: 0.0;}
35% {transform: rotate3d(0, 0, 0, 0deg); opacity: 1.0;}
45% {transform: rotate3d(0, 0, 0, 0deg); opacity: 1.0;}
50% {transform: rotate3d(1, 0, 0, 100deg); opacity: 0.0;}
100% {transform: rotate3d(0, 0, 0, 0deg); opacity: 0.0;}
}
#keyframes effect-crescer {
0% {transform: rotate3d(0, 0, 0, 0deg); opacity: 0.0;}
30% {transform: rotate3d(1, 0, 0, 100deg); opacity: 0.0;}
35% {transform: rotate3d(0, 0, 0, 0deg); opacity: 1.0;}
45% {transform: rotate3d(0, 0, 0, 0deg); opacity: 1.0;}
50% {transform: rotate3d(1, 0, 0, 100deg); opacity: 0.0;}
100% {transform: rotate3d(0, 0, 0, 0deg); opacity: 0.0;}
}
#-webkit-keyframes effect-acontecer {
0% {transform: rotate3d(0, 0, 0, 0deg); opacity: 0.0;}
50% {transform: rotate3d(1, 0, 0, 100deg); opacity: 0.0;}
55% {transform: rotate3d(0, 0, 0, 0deg); opacity: 1.0;}
65% {transform: rotate3d(0, 0, 0, 0deg); opacity: 1.0;}
70% {transform: rotate3d(1, 0, 0, 100deg); opacity: 0.0;}
100% {transform: rotate3d(0, 0, 0, 0deg); opacity: 0.0;}
}
#keyframes effect-acontecer {
0% {transform: rotate3d(0, 0, 0, 0deg); opacity: 0.0;}
50% {transform: rotate3d(1, 0, 0, 100deg); opacity: 0.0;}
55% {transform: rotate3d(0, 0, 0, 0deg); opacity: 1.0;}
65% {transform: rotate3d(0, 0, 0, 0deg); opacity: 1.0;}
70% {transform: rotate3d(1, 0, 0, 100deg); opacity: 0.0;}
100% {transform: rotate3d(0, 0, 0, 0deg); opacity: 0.0;}
}
#-webkit-keyframes effect-acreditar {
0% {transform: rotate3d(0, 0, 0, 0deg); opacity: 0.0;}
70% {transform: rotate3d(1, 0, 0, 100deg); opacity: 0.0;}
75% {transform: rotate3d(0, 0, 0, 0deg); opacity: 1.0;}
85% {transform: rotate3d(0, 0, 0, 0deg); opacity: 1.0;}
90% {transform: rotate3d(1, 0, 0, 100deg); opacity: 0.0;}
100% {transform: rotate3d(0, 0, 0, 0deg); opacity: 0.0;}
}
#keyframes effect-acreditar {
0% {transform: rotate3d(0, 0, 0, 0deg); opacity: 0.0;}
70% {transform: rotate3d(1, 0, 0, 100deg); opacity: 0.0;}
75% {transform: rotate3d(0, 0, 0, 0deg); opacity: 1.0;}
85% {transform: rotate3d(0, 0, 0, 0deg); opacity: 1.0;}
90% {transform: rotate3d(1, 0, 0, 100deg); opacity: 0.0;}
100% {transform: rotate3d(0, 0, 0, 0deg); opacity: 0.0;}
}
<div class="anima-box">
<div class="anima-fazer"></div>
<div class="anima-evoluir"></div>
<div class="anima-crescer"></div>
<div class="anima-acontecer"></div>
<div class="anima-acreditar"></div>
</div>
This is my code for CSS3 animation: shake that I applied on one of the nav links. It works like a charm, but I want it turned off when someone opens the page that it is linked to it.
How can I solve this problem?
#menu-item-313 {
animation: shake 1.4s;
-webkit-animation-iteration-count: 10; /* Chrome, Safari, Opera */
animation-iteration-count: 6;
transform: translate3d(0, 0, 0);
}
#keyframes shake {
10%, 90% {
transform: translate3d(-2px, 0, 0);
}
20%, 80% {
transform: translate3d(4px, 0, 0);
}
30%, 50%, 70% {
transform: translate3d(-8px, 0, 0);
}
40%, 60% {
transform: translate3d(8px, 0, 0);
}
}
One way is to set a class on the body, like this, and use the :not selector
Sample not shaking
body:not(.pg313) #menu-item-313 {
animation: shake 1.4s;
-webkit-animation-iteration-count: 10; /* Chrome, Safari, Opera */
animation-iteration-count: 6;
transform: translate3d(0, 0, 0);
}
#keyframes shake {
10%, 90% {
transform: translate3d(-2px, 0, 0);
}
20%, 80% {
transform: translate3d(4px, 0, 0);
}
30%, 50%, 70% {
transform: translate3d(-8px, 0, 0);
}
40%, 60% {
transform: translate3d(8px, 0, 0);
}
}
<body class="pg313">
<div id="menu-item-313">
Menu item 313
</div>
<div id="menu-item-314">
Menu item 314
</div>
</body>
Sample shaking
body:not(.pg313) #menu-item-313 {
animation: shake 1.4s;
-webkit-animation-iteration-count: 10; /* Chrome, Safari, Opera */
animation-iteration-count: 6;
transform: translate3d(0, 0, 0);
}
#keyframes shake {
10%, 90% {
transform: translate3d(-2px, 0, 0);
}
20%, 80% {
transform: translate3d(4px, 0, 0);
}
30%, 50%, 70% {
transform: translate3d(-8px, 0, 0);
}
40%, 60% {
transform: translate3d(8px, 0, 0);
}
}
<body class="pg314">
<div id="menu-item-313">
Menu item 313
</div>
<div id="menu-item-314">
Menu item 314
</div>
</body>
I am trying to make image shake on hover with CSS3 but seems like I have syntax error. I am trying the apply the effect to css3.png and html5.png
I have added id classes to the images that I would like to have that effect.
Here is my current html:
<div class="row">
<div class="col-lg-2 col-lg-offset-2">
<div id="img">
<img class="img-responsive shake" src="img/html5.png">
</div>
</div>
<div class="col-lg-3">
<img class="img-responsive" src="img/and.png">
</div>
<div class="col-lg-2">
<div id="img">
<img class="img-responsive shake" src="img/css3.png">
</div>
</div>
</div>
here is the CSS:
.shake {
-webkit-animation-name: shake;
animation-name: shake;
}
#-webkit-keyframes shake {
from, to {
-webkit-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0);
}
10%, 30%, 50%, 70%, 90% {
-webkit-transform: translate3d(-10px, 0, 0);
transform: translate3d(-10px, 0, 0);
}
20%, 40%, 60%, 80% {
-webkit-transform: translate3d(10px, 0, 0);
transform: translate3d(10px, 0, 0);
}
}
#keyframes shake {
from, to {
-webkit-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0);
}
10%, 30%, 50%, 70%, 90% {
-webkit-transform: translate3d(-10px, 0, 0);
transform: translate3d(-10px, 0, 0);
}
20%, 40%, 60%, 80% {
-webkit-transform: translate3d(10px, 0, 0);
transform: translate3d(10px, 0, 0);
}
}
To get the effect on hover, you have to include the :hover selector in your css: http://www.w3schools.com/cssref/sel_hover.asp
.shake img:hover {
***code***
}
Try replacing
.shake {
-webkit-animation-name: shake;
animation-name: shake;
}
with this CSS.
.shake:hover {
-webkit-animation-name: shake;
animation-name: shake;
-webkit-animation-duration: 2s;
animation-duration: 2s;
}
Your problem is that .shake is calling a div that you are not using in your HTML. First, take the spaces out of your div classes, it is bad naming convention... Then call those divs instead of ".shake" It would be closer to this
# .img-responsive-shake{
enter code here
}
I'm using animate.css for a CSS3 shake effect, the CSS looks like the snippet below. Right now it shakes back and forth multiple times and I'd like to cut the shakes in half. Is there a way to do this with animate css3 or do I need to modify the css3 below? If so, what's the best way?
#-webkit-keyframes shake {
0%, 100% {
-webkit-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0);
}
10%, 30%, 50%, 70%, 90% {
-webkit-transform: translate3d(-10px, 0, 0);
transform: translate3d(-10px, 0, 0);
}
20%, 40%, 60%, 80% {
-webkit-transform: translate3d(10px, 0, 0);
transform: translate3d(10px, 0, 0);
}
}
#keyframes shake {
0%, 100% {
-webkit-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0);
}
10%, 30%, 50%, 70%, 90% {
-webkit-transform: translate3d(-10px, 0, 0);
transform: translate3d(-10px, 0, 0);
}
20%, 40%, 60%, 80% {
-webkit-transform: translate3d(10px, 0, 0);
transform: translate3d(10px, 0, 0);
}
}
.shake {
-webkit-animation-name: shake;
animation-name: shake;
}
Not really sure how you want to "cut the shake in half". Do you mean the speed, sway??
Here is what I came up, demo
If you want to slow the animation down, change the `-webkit-animation-duration:
Here is a custom cool shake/wobble effect:
#keyframes shake {
0% {
-webkit-transform:translate(2px,1px) rotate(0deg)
}
10% {
-webkit-transform:translate(-1px,-2px) rotate(-1deg)
}
20% {
-webkit-transform:translate(-3px,0px) rotate(1deg)
}
30% {
-webkit-transform:translate(0px,2px) rotate(0deg)
}
40% {
-webkit-transform:translate(1px,-1px) rotate(1deg)
}
50% {
-webkit-transform:translate(-1px,2px) rotate(-1deg)
}
60% {
-webkit-transform:translate(-3px,1px) rotate(0deg)
}
70% {
-webkit-transform:translate(2px,1px) rotate(-1deg)
}
80% {
-webkit-transform:translate(-1px,-1px) rotate(1deg)
}
90% {
-webkit-transform:translate(2px,2px) rotate(0deg)
}
100% {
-webkit-transform:translate(1px,-2px) rotate(-1deg)
}
}
Here is a simple demo