I have the following snippet of CSS:
#-webkit-keyframes spin {
0% { -webkit-transform: rotate(0deg);}
100% { -webkit-transform: rotate(360deg);}
}
#-moz-keyframes spin {
0% { -moz-transform: rotate(0deg);}
100% { -moz-transform: rotate(360deg);}
}
#-o-keyframes spin {
0% { -o-transform: rotate(0deg);}
100% { -o-transform: rotate(360deg);}
}
#-ms-keyframes spin {
0% { -ms-transform: rotate(0deg);}
100% { -ms-transform: rotate(360deg);}
}
#-keyframes spin {
0% { transform: rotate(0deg);}
100% { transform: rotate(360deg);}
}
header .spinner {
position: absolute;
width: 100%;
text-align: center;
margin: 0 auto;
left: 0;
-webkit-animation:spin 1s ease-out .5s;
-moz-animation:spin 1s ease-out .5s;
animation:spin 1s ease-out .5s;
transform-origin: 50%;
}
the animation runs fine, however the origin is slightly wrong making it look like the img is jumping when rotating.
Related
Not really aware how to use CSS animations, but I found something that works perfectly for my site. The one issue, is it's way too small. Anyone have any advice for what I would need to tinker with to expand the size? I actually see where to increase the size/scale towards the end of the animation, which is made obvious with the scale attributes. What I don't know, is controlling the size before the animation causes it to expand. Thank you very much. -Wilson
Ex:
http://www.wilsonschlamme.com/animationtest.html
css:
.overlay-loader .loader-icon {
position: absolute;
top: 50%;
left: 44%;
color: #42f498;
}
.overlay-loader .loader-icon.spinning-cog {
-webkit-animation: spinning-cog 1.3s infinite ease;
-moz-animation: spinning-cog 1.3s infinite ease;
-ms-animation: spinning-cog 1.3s infinite ease;
-o-animation: spinning-cog 1.3s infinite ease;
animation: spinning-cog 1.3s infinite ease;
background-color: #42f498;
}
#-webkit-keyframes spinning-cog {
0% { -webkit-transform: rotate(0deg) }
20% { -webkit-transform: rotate(-45deg) }
100% { -webkit-transform: rotate(360deg) }
}
#-moz-keyframes spinning-cog {
0% { -moz-transform: rotate(0deg) }
20% { -moz-transform: rotate(-45deg) }
100% { -moz-transform: rotate(360deg) }
}
#-o-keyframes spinning-cog {
0% { -o-transform: rotate(0deg) }
20% { -o-transform: rotate(-45deg) }
100% { -o-transform: rotate(360deg) }
}
#keyframes spinning-cog {
0% { transform: rotate(0deg) }
20% { transform: rotate(-45deg) }
100% { transform: rotate(360deg) }
}
#-webkit-keyframes shrinking-cog {
0% { -webkit-transform: scale(2) }
20% { -webkit-transform: scale(2.2) }
100% { -webkit-transform: scale(1) }
}
#-moz-keyframes shrinking-cog {
0% { -moz-transform: scale(2) }
20% { -moz-transform: scale(2.2) }
100% { -moz-transform: scale(1) }
}
#-o-keyframes shrinking-cog {
0% { -o-transform: scale(2) }
20% { -o-transform: scale(2.2) }
100% { -o-transform: scale(1) }
}
#keyframes shrinking-cog {
0% { transform: scale(2) }
20% { transform: scale(2.2) }
100% { transform: scale(0) }
}
.overlay-loader .loader-icon.shrinking-cog {
-webkit-animation: shrinking-cog .3s 1 ease forwards;
-moz-animation: shrinking-cog .3s 1 ease forwards;
-ms-animation: shrinking-cog .3s 1 ease forwards;
-o-animation: shrinking-cog .3s 1 ease forwards;
animation: shrinking-cog .3s 1 ease forwards;
background-color: #42f498;
}
If you want it to be big from the start of the animation, add scale to spinning-cog animation. do this to all prefixes (change x to what scale you want)
#keyframes spinning-cog {
0% { transform: rotate(0deg) scale(x)}
20% { transform: rotate(-45deg) scale(x)}
100% { transform: rotate(360deg) scale(x)}
}
To terrify the guys at Pixar (with my animation skills), I am attempting to get a walking effect to work using CSS ...
Unfortunately, I am unable to work two different animation effects in parallel, I want the steps to rotate at a variable rate to the walkRight transition.
Here is my current attempt:
CSS
.wrapper {
position: absolute;
width: 100px;
height: 100px;
right: 0;
animation-name: walkRight;
animation-iteration-count: 1;
animation-timing-function: ease-out;
animation-duration: 10s;
}
.hulk {
-webkit-animation: steps 10s linear 0s;
}
#keyframes walkRight {
0% {
transform: translateX(-400px);
}
100% {
transform: translateX(0);
}
}
#-webkit-keyframes steps {
0% {
-webkit-transform: rotate(0deg);
}
25% {
-webkit-transform: rotate(20deg);
}
50% {
-webkit-transform: rotate(0deg);
}
75% {
-webkit-transform: rotate(-20deg);
}
100% {
-webkit-transform: rotate(0deg);
}
}
Here is an example JsFiddle
You could try to:
Use animation-iteration-count: 10 on hulk class and set is duration to 1s (as walkRight has 10s duration), this means the walk effect will be applied 10 times during the walk.
Prefix all properties using -webkit- to make sure browsers will render your animation properly, you could use autoprefixer (or similar) which does the job for you automatically.
.wrapper {
position: absolute;
width: 100px;
height: 100px;
right: 0;
-webkit-animation-name: walkRight;
animation-name: walkRight;
-webkit-animation-timing-function: ease-out;
animation-timing-function: ease-out;
-webkit-animation-duration: 10s;
animation-duration: 10s;
}
.hulk {
-webkit-animation: steps 1s linear 0s;
-webkit-animation-iteration-count: 10;
animation-iteration-count: 10;
}
#-webkit-keyframes walkRight {
0% {
-webkit-transform: translateX(-400px);
transform: translateX(-400px);
}
100% {
-webkit-transform: translateX(0);
transform: translateX(0);
}
}
#keyframes walkRight {
0% {
-webkit-transform: translateX(-400px);
transform: translateX(-400px);
}
100% {
-webkit-transform: translateX(0);
transform: translateX(0);
}
}
#-webkit-keyframes steps {
0% {
-webkit-transform: rotate(0deg);
}
25% {
-webkit-transform: rotate(20deg);
}
50% {
-webkit-transform: rotate(0deg);
}
75% {
-webkit-transform: rotate(-20deg);
}
100% {
-webkit-transform: rotate(0deg);
}
}
<div class="wrapper">
<img class="hulk" width="100px" src="http://vignette3.wikia.nocookie.net/heroup/images/4/4b/Thing_full_body.png/revision/latest?cb=20120117152657">
</div>
You can use animation-iteration-count on steps animation and set shorter duration. You just need to match ending time for both walk and steps that will repeat itself n number of times, so in this case its about 9 if duration is 1s.
.wrapper {
position: absolute;
width: 100px;
height: 100px;
right: 0;
animation-name: walkRight;
animation-iteration-count: 1;
animation-timing-function: ease-out;
animation-duration: 10s;
}
.hulk {
-webkit-animation: steps 1s linear 0s;
animation-iteration-count: 9;
}
#keyframes walkRight {
0% {
transform: translateX(-400px);
}
100% {
transform: translateX(0);
}
}
#-webkit-keyframes steps {
0% {
-webkit-transform: rotate(0deg);
}
25% {
-webkit-transform: rotate(20deg);
}
50% {
-webkit-transform: rotate(0deg);
}
75% {
-webkit-transform: rotate(-20deg);
}
100% {
-webkit-transform: rotate(0deg);
}
}
<div class="wrapper">
<img class="hulk" width="100px" src="http://vignette3.wikia.nocookie.net/heroup/images/4/4b/Thing_full_body.png/revision/latest?cb=20120117152657">
</div>
I'm creating a CSS keyframe animation to have an element appear as if it is casually/slowly floating around a bit. It's nested in parents, one which uses translateX() to slowly move it left and right, and one which uses translateY() to slowly and independently move it up and down.
Chrome and Safari render this perfectly, giving it a gradual swaying movement. It smooths the animation (perhaps using sub-pixel smoothing?) so that everything appears very smooth. Firefox however, animates it pixel by pixel, so rather than smoothly swaying about, you can see it jump at every pixel.
View the JSFiddle in Chrome and FireFox to view the difference: http://jsfiddle.net/gonygdfz/6/
Is there any way to make FireFox render this smoothly rather than having it jumping pixel by pixel? It's extremely noticeable in the actual application for this.
The Markup:
<div id="parent">
<div id="move-x">
<div id="move-y">
<div id="child"></div>
</div>
</div>
</div>
The CSS:
#parent {
width: 400px;
height: 326px;
background-color: yellow;
background: url(http://paint.net.amihotornot.com.au/Features/Effects/Plugins/Render/Grid_CheckerBoard_Maker/Grid_CheckerBoard_Maker.Paint.NET.001.png) top center repeat;
}
#child {
position: absolute;
top: 75px;
left: 150px;
width: 100px;
height: 100px;
background-color: black;
animation: range-y 10s infinite ease;
}
#move-x {
animation: range-x 10s infinite ease;
-webkit-animation: range-x 10s infinite ease;
}
#move-y {
animation: range-y 15s infinite ease;
-webkit-animation: range-y 15s infinite ease;
}
#keyframes range-x {
0% {
transform: translateX(0);
}
30% {
transform: translateX(-8px);
}
50% {
transform: translateX(1px);
}
65% {
transform: translateX(6px);
}
80% {
transform: translateX(0px);
}
89% {
transform: translateX(-3px);
}
100% {
transform: translateX(0);
}
}
#keyframes range-y {
0% {
transform: translateY(0);
}
20% {
transform: translateY(13px);
}
35% {
transform: translateY(-1px);
}
70% {
transform: translateY(-14px);
}
90% {
transform: translateY(2px);
}
100% {
transform: translateY(0);
}
}
#-webkit-keyframes range-x {
0% {
transform: translateX(0);
}
30% {
transform: translateX(-8px);
}
50% {
transform: translateX(1px);
}
65% {
transform: translateX(6px);
}
80% {
transform: translateX(0px);
}
89% {
transform: translateX(-3px);
}
100% {
transform: translateX(0);
}
}
#-webkit-keyframes range-y {
0% {
transform: translateY(0);
}
20% {
transform: translateY(13px);
}
35% {
transform: translateY(-1px);
}
70% {
transform: translateY(-14px);
}
90% {
transform: translateY(2px);
}
100% {
transform: translateY(0);
}
}
The rendering engines for each browser is obviously different. Firefox does not implement an anti-aliasing effect on CSS animations. This does not inherently make it better or worse, it just depends on what you are animating. Linear transitions can appear undesirably blurred in Chrome for example.
It appears what you would like to achieve is to have an anti-aliased/sub-pixel smoothed transitions. We can't change the way the engine renders but we can manipulate the animation to appear softer to the end user.
ALL IS NOT LOST
I have modified your answer and rendered a smoother version next to your original. This should appear softer when viewed in Firefox.
CLICK FOR COMPARISON
Techniques used for this effect:
Linear transitions instead of ease.
Box-shadow on animated object. (Softened edge helps create fake AA effect).
Rotate object. Adding the smallest rotate helps to better utilised the rendering engine.
CSS
#parent {
width: 50%;
float:left;
height: 326px;
background-color: yellow;
background: url(http://paint.net.amihotornot.com.au/Features/Effects/Plugins/Render/Grid_CheckerBoard_Maker/Grid_CheckerBoard_Maker.Paint.NET.001.png) top center repeat;
}
#child {
position: absolute;
top: 75px;
left: 150px;
width: 100px;
height: 100px;
background-color: black;
box-shadow:0 0 1px rgba(0,0,0,0.7);
animation: range-y 10s infinite linear;
-webkit-animation: range-y 10s infinite linear;
}
#move-x {
animation: range-x 10s infinite linear;
-webkit-animation: range-x 10s infinite linear;
}
#move-y {
animation: range-y 15s infinite linear;
-webkit-animation: range-y 15s infinite linear;
}
#keyframes range-x {
0% {transform: translateX(0);}
30% {transform: translateX(-8px) rotate(0.02deg);}
50% {transform: translateX(1px) rotate(0deg);}
65% {transform: translateX(6px) rotate(0.02deg);}
80% {transform: translateX(0px) rotate(0deg);}
89% {transform: translateX(-3px) rotate(0.02deg);}
100% {transform: translateX(0) rotate(0deg);}
}
#keyframes range-y {
0% {transform: translateY(0);}
20% {transform: translateY(13px) rotate(0.02deg);}
35% {transform: translateY(-1px) rotate(0deg);}
70% {transform: translateY(-14px) rotate(0.02deg);}
90% {transform: translateY(2px) rotate(0deg);}
100% {transform: translateY(0) rotate(0.02deg);}
}
#-webkit-keyframes range-x {
0% {transform: translateX(0);}
30% {transform: translateX(-8px) rotate(0.02deg);}
50% {transform: translateX(1px) rotate(0deg);}
65% {transform: translateX(6px) rotate(0.02deg);}
80% {transform: translateX(0px) rotate(0deg);}
89% {transform: translateX(-3px) rotate(0.02deg);}
100% {transform: translateX(0) rotate(0deg);}
}
#-webkit-keyframes range-y {
0% {transform: translateY(0);}
20% {transform: translateY(13px) rotate(0.02deg);}
35% {transform: translateY(-1px) rotate(0deg);}
70% {transform: translateY(-14px) rotate(0.02deg);}
90% {transform: translateY(2px) rotate(0deg);}
100% {transform: translateY(0) rotate(0.02deg);}
}
FINAL WORD
You can still tweak the effects a little either way to fit your requirements.
It's not perfect but I hope it helps soften the end effect for your actual animation.
Use a small amount of rotation with the transformation. This forces Firefox to avoid the optimization and resample the image on every frame.
#keyframes optimized {
0%{
transform: translateX(0%);
}
100%{
transform: translateX(200px);
}
}
#keyframes subpixel {
0%{
transform: translateX(0%) rotate(0.1deg);
}
100%{
transform: translateX(200px) rotate(0.1deg);
}
}
div{
width:5px;
height:50px;
background-color: red;
animation-duration:30s;
animation-iteration-count: infinite;
animation-direction:alternate;
animation-timing-function:linear;
}
.optimized{
animation-name: optimized;
margin-bottom:1px;
}
.subpixel{
animation-name: subpixel;
}
<div class="optimized">
</div>
<div class="subpixel">
</div>
I am currently working on sidebar navigation for a mobile site and I am trying to include the below animation for the main menu button.
This works well on different browsers except for mobile devices running iOS - Safari and Android - Android Browser. What am I missing? Thanks.
http://jsfiddle.net/wvck5xnL/
HTML
<div class="mainBtn">
<input id="mainmenuBtn" name="exit" type="checkbox" />
<label for="mainmenuBtn"><span class="burger"></span></label>
</div>
CSS
body {
padding:0;
margin:0;
overflow: hidden;
background:white;
}
/* burger icon animation */
.mainBtn{
display: block;
width: 40px;
padding-left: 10px;
text-align: left;
}
.mainBtn input {
display: none;
}
.mainBtn label {
position: relative;
width: 48px;
height: 57px;
display: block;
cursor: pointer;
background: transparent;
}
/* Exit Icon */
.mainBtn label:before,
.mainBtn input:checked + label:before {
content: '';
position: absolute;
top: 50%;
margin-top: -2px;
width: 30px;
height: 4px;
border-radius: 2px;
background: black;
}
.mainBtn label:before {
-webkit-animation: animationOneReverse 1s ease forwards;
-moz-animation: animationOneReverse 1s ease forwards;
-o-animation: animationOneReverse 1s ease forwards;
-ms-animation: animationOneReverse 1s ease forwards;
animation: animationOneReverse 1s ease forwards;
}
#-webkit-keyframes animationOneReverse {
0% { -webkit-transform: rotate(315deg); }
50%, 100% { -webkit-transform: rotate(0deg); }
}
#-moz-keyframes animationOneReverse {
0% { -moz-transform: rotate(315deg); }
50%, 100% { -moz-transform: rotate(0deg); }
}
#-o-keyframes animationOneReverse {
0% { -o-transform: rotate(315deg); }
50%, 100% { -o-transform: rotate(0deg); }
}
#-ms-keyframes animationOneReverse {
0% { -ms-transform: rotate(315deg); }
50%, 100% { -ms-transform: rotate(0deg); }
}
#keyframes animationOneReverse {
0% { transform: rotate(315deg); }
50%, 100% { transform: rotate(0deg); }
}
.mainBtn input:checked + label:before {
-webkit-animation: animationOne 1s ease forwards;
-moz-animation: animationOne 1s ease forwards;
-o-animation: animationOne 1s ease forwards;
-ms-animation: animationOne 1s ease forwards;
animation: animationOne 1s ease forwards;
}
#-webkit-keyframes animationOne {
0%, 50% { -webkit-transform: rotate(0deg); }
100% { -webkit-transform: rotate(315deg); }
}
#-moz-keyframes animationOne {
0% { -moz-transform: rotate(0deg); }
50%, 100% { -moz-transform: rotate(315deg); }
}
#-o-keyframes animationOne {
0% { -o-transform: rotate(0deg); }
50%, 100% { -o-transform: rotate(315deg); }
}
#-ms-keyframes animationOne {
0% { -ms-transform: rotate(0deg); }
50%, 100% { -ms-transform: rotate(315deg); }
}
#keyframes animationOne {
0%, 50% { transform: rotate(0deg); }
100% { transform: rotate(315deg); }
}
.mainBtn label:after,
.mainBtn input:checked + label:after {
content: '';
position: absolute;
top: 50%;
margin-top: -2px;
width: 30px;
height: 4px;
border-radius: 2px;
background: black;
}
.mainBtn label:after {
-webkit-animation: animationTwoReverse 1s ease forwards;
-moz-animation: animationTwoReverse 1s ease forwards;
-o-animation: animationTwoReverse 1s ease forwards;
-ms-animation: animationTwoReverse 1s ease forwards;
animation: animationTwoReverse 1s ease forwards;
}
#-webkit-keyframes animationTwoReverse {
0% { -webkit-transform: rotate(405deg); }
50%, 100% { -webkit-transform: rotate(0deg); }
}
#-moz-keyframes animationTwoReverse {
0% { -moz-transform: rotate(405deg); }
50%, 100% { -moz-transform: rotate(0deg); }
}
#-o-keyframes animationTwoReverse {
0% { -o-transform: rotate(405deg); }
50%, 100% { -o-transform: rotate(0deg); }
}
#-ms-keyframes animationTwoReverse {
0% { -ms-transform: rotate(405deg); }
50%, 100% { -ms-transform: rotate(0deg); }
}
#keyframes animationTwoReverse {
0% { transform: rotate(405deg); }
50%, 100% { transform: rotate(0deg); }
}
.mainBtn input:checked + label:after {
-webkit-animation: animationTwo 1s ease forwards;
-moz-animation: animationTwo 1s ease forwards;
-o-animation: animationTwo 1s ease forwards;
-ms-animation: animationTwo 1s ease forwards;
animation: animationTwo 1s ease forwards;
}
#-webkit-keyframes animationTwo {
0%, 50% { -webkit-transform: rotate(0deg); }
100% { -webkit-transform: rotate(405deg); }
}
#-moz-keyframes animationTwo {
0% { -moz-transform: rotate(0deg); }
50%, 100% { -moz-transform: rotate(405deg); }
}
#-o-keyframes animationTwo {
0% { -o-transform: rotate(0deg); }
50%, 100% { -o-transform: rotate(405deg); }
}
#-ms-keyframes animationTwo {
0% { -ms-transform: rotate(0deg); }
50%, 100% { -ms-transform: rotate(405deg); }
}
#keyframes animationTwo {
0%, 50% { transform: rotate(0deg); }
100% { transform: rotate(405deg); }
}
/* Burger Icon */
.mainBtn label .burger:before {
content: '';
position: absolute;
top: 17px;
width: 30px;
height: 4px;
border-radius: 2px;
background: black;
-webkit-animation: animationBurgerTopReverse 1s ease forwards;
-moz-animation: animationBurgerTopReverse 1s ease forwards;
-o-animation: animationBurgerTopReverse 1s ease forwards;
-ms-animation: animationBurgerTopReverse 1s ease forwards;
animation: animationBurgerTopReverse 1s ease forwards;
}
#-webkit-keyframes animationBurgerTopReverse {
0%, 50% { -webkit-transform: translateY(12px); opacity: 0; }
51% { -webkit-transform: translateY(12px); opacity: 1; }
100% { -webkit-transform: translateY(0px); opacity: 1; }
}
#-moz-keyframes animationBurgerTopReverse {
0%, 50% { -moz-transform: translateY(12px); opacity: 0; }
51% { -moz-transform: translateY(12px); opacity: 1; }
100% { -moz-transform: translateY(0px); opacity: 1; }
}
#-o-keyframes animationBurgerTopReverse {
0%, 50% { -o-transform: translateY(12px); opacity: 0; }
51% { -o-transform: translateY(12px); opacity: 1; }
100% { -o-transform: translateY(0px); opacity: 1; }
}
#-ms-keyframes animationBurgerTopReverse {
0%, 50% { -ms-transform: translateY(12px); opacity: 0; }
51% { -ms-transform: translateY(12px); opacity: 1; }
100% { -ms-transform: translateY(0px); opacity: 1; }
}
#keyframes animationBurgerTopReverse {
0%, 50% { transform: translateY(12px); opacity: 0; }
51% { transform: translateY(12px); opacity: 1; }
100% { transform: translateY(0px); opacity: 1; }
}
.mainBtn input:checked + label .burger:before {
-webkit-animation: animationBurgerTop 1s ease forwards;
-moz-animation: animationBurgerTop 1s ease forwards;
-o-animation: animationBurgerTop 1s ease forwards;
-ms-animation: animationBurgerTop 1s ease forwards;
animation: animationBurgerTop 1s ease forwards;
}
#-webkit-keyframes animationBurgerTop {
0% { -webkit-transform: translateY(0px); opacity: 1; }
50% { -webkit-transform: translateY(12px); opacity: 1; }
51%, 100% { -webkit-transform: translateY(12px); opacity: 0; }
}
#-moz-keyframes animationBurgerTop {
0% { -moz-transform: translateY(0px); opacity: 1; }
50% { -moz-transform: translateY(12px); opacity: 1; }
51%, 100% { -moz-transform: translateY(12px); opacity: 0; }
}
#-o-keyframes animationBurgerTop {
0% { -o-transform: translateY(0px); opacity: 1; }
50% { -o-transform: translateY(12px); opacity: 1; }
51%, 100% { -o-transform: translateY(12px); opacity: 0; }
}
#-ms-keyframes animationBurgerTop {
0% { -ms-transform: translateY(0px); opacity: 1; }
50% { -ms-transform: translateY(12px); opacity: 1; }
51%, 100% { -ms-transform: translateY(12px); opacity: 0; }
}
#keyframes animationBurgerTop {
0% { transform: translateY(0px); opacity: 1; }
50% { transform: translateY(12px); opacity: 1; }
51%, 100% { transform: translateY(12px); opacity: 0; }
}
.mainBtn label .burger:after {
content: '';
position: absolute;
bottom: 16px;
width: 30px;
height: 4px;
border-radius: 2px;
background: black;
-webkit-animation: animationBurgerBottomReverse 1s ease forwards;
-moz-animation: animationBurgerBottomReverse 1s ease forwards;
-o-animation: animationBurgerBottomReverse 1s ease forwards;
-ms-animation: animationBurgerBottomReverse 1s ease forwards;
animation: animationBurgerBottomReverse 1s ease forwards;
}
#-webkit-keyframes animationBurgerBottomReverse {
0%, 50% { -webkit-transform: translateY(-12px); opacity: 0; }
51% { -webkit-transform: translateY(-12px); opacity: 1; }
100% { -webkit-transform: translateY(0px); opacity: 1; }
}
#-moz-keyframes animationBurgerBottomReverse {
0%, 50% { -moz-transform: translateY(-12px); opacity: 0; }
51% { -moz-transform: translateY(-12px); opacity: 1; }
100% { -moz-transform: translateY(0px); opacity: 1; }
}
#-o-keyframes animationBurgerBottomReverse {
0%, 50% { -o-transform: translateY(-12px); opacity: 0; }
51% { -o-transform: translateY(-12px); opacity: 1; }
100% { -o-transform: translateY(0px); opacity: 1; }
}
#-ms-keyframes animationBurgerBottomReverse {
0%, 50% { -ms-transform: translateY(-12px); opacity: 0; }
51% { -ms-transform: translateY(-12px); opacity: 1; }
100% { -ms-transform: translateY(0px); opacity: 1; }
}
#keyframes animationBurgerBottomReverse {
0%, 50% { transform: translateY(-12px); opacity: 0; }
51% { transform: translateY(-12px); opacity: 1; }
100% { transform: translateY(0px); opacity: 1; }
}
.mainBtn input:checked + label .burger:after {
-webkit-animation: animationBurgerBottom 1s ease forwards;
-moz-animation: animationBurgerBottom 1s ease forwards;
-o-animation: animationBurgerBottom 1s ease forwards;
-ms-animation: animationBurgerBottom 1s ease forwards;
animation: animationBurgerBottom 1s ease forwards;
}
#-webkit-keyframes animationBurgerBottom {
0% { -webkit-transform: translateY(0px); opacity: 1; }
50% { -webkit-transform: translateY(-12px); opacity: 1; }
51%, 100% { -webkit-transform: translateY(-12px); opacity: 0; }
}
#-moz-keyframes animationBurgerBottom {
0% { -moz-transform: translateY(0px); opacity: 1; }
50% { -moz-transform: translateY(-12px); opacity: 1; }
51%, 100% { -moz-transform: translateY(-12px); opacity: 0; }
}
#-o-keyframes animationBurgerBottom {
0% { -o-transform: translateY(0px); opacity: 1; }
50% { -o-transform: translateY(-12px); opacity: 1; }
51%, 100% { -o-transform: translateY(-12px); opacity: 0; }
}
#-ms-keyframes animationBurgerBottom {
0% { -ms-transform: translateY(0px); opacity: 1; }
50% { -ms-transform: translateY(-12px); opacity: 1; }
51%, 100% { -ms-transform: translateY(-12px); opacity: 0; }
}
#keyframes animationBurgerBottom {
0% { transform: translateY(0px); opacity: 1; }
50% { transform: translateY(-12px); opacity: 1; }
51%, 100% { transform: translateY(-12px); opacity: 0; }
}
Hi I tried your fiddle and it worked on my mobile, which is iphone5s.
But anyway, as far as I've known, when you want to use keyframes-translate for an element. The element has to be displayed block, or it has to be wrapped by a div, which default is displayed block too.
a {
background:orange;
}
div {
-webkit-animation: move 5s infinite;
}
#-webkit-keyframes move {
0% { -webkit-transform: translate(20px); }
100% { -webkit-transform: translate(500px); }
}
<div class="wrapper">Test</div>
I'm thinking maybe translate doesn't support some elements completely. For instance, when you want to translate a tag element, you have to set the element display: block.
However, when you want to apply translate on a div element, if you set the css on the div element display:inline-block, the translate will still work on that div.
So maybe try to set the elements that you'd like to move display:block.
I'm trying to animate a div on mouseout with keyframes animation :
div{
-webkit-transition: -webkit-animation:flipInY 2s;
}
div:hover{
-webkit-animation: flipInY 0.8s;
}
So when the user mouseout there will be some transition,but i want to do this using animation keyframes not with normal transition:
#-webkit-keyframes flipInY {
0% {
-webkit-transform: perspective(400px) rotateY(90deg);
opacity: 0;
}
40% {
-webkit-transform: perspective(400px) rotateY(-10deg);
}
70% {
-webkit-transform: perspective(400px) rotateY(10deg);
}
100% {
-webkit-transform: perspective(400px) rotateY(0deg);
opacity: 1;
}
}