Flipping an icon and spinning it in reverse - html

There's an icon in the Font Awesome set that I want to flip horizontally and then spin in that direction, which is the opposite of the regular spin effect.
There are a number of ways to do each, but none that I know that will do both since the effects seem to cancel each other out?
If I flip it,
.fa-refresh {
-moz-transform: scaleX(-1);
-o-transform: scaleX(-1);
-webkit-transform: scaleX(-1);
transform: scaleX(-1);
filter: FlipH;
-ms-filter: "FlipH";
}
then animate it,
.icon-spin-reverse {
display: inline-block;
-moz-animation: spin-reverse 2s infinite linear;
-o-animation: spin-reverse 2s infinite linear;
-webkit-animation: spin-reverse 2s infinite linear;
animation: spin-reverse 2s infinite linear;
}
#-moz-keyframes spin-reverse {
0% { -moz-transform: rotate(0deg); }
100% { -moz-transform: rotate(-359deg); }
}
#-webkit-keyframes spin-reverse {
0% { -webkit-transform: rotate(0deg); }
100% { -webkit-transform: rotate(-359deg); }
}
#-o-keyframes spin-reverse {
0% { -o-transform: rotate(0deg); }
100% { -o-transform: rotate(-359deg); }
}
#-ms-keyframes spin-reverse {
0% { -ms-transform: rotate(0deg); }
100% { -ms-transform: rotate(-359deg); }
}
#keyframes spin-reverse {
0% { transform: rotate(0deg); }
100% { transform: rotate(-359deg); }
}
the flip will be canceled, and it will just spin in reverse.
Is there any way to do both?

Your animation is overriding the initial transform. You need to apply both of the transforms in your animation:
.fa-refresh {
transform: scaleX(-1);
animation: spin-reverse 2s infinite linear;
}
#keyframes spin-reverse {
0% {
transform: scaleX(-1) rotate(-360deg);
}
100% {
transform: scaleX(-1) rotate(0deg);
}
}
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
<i class="fa fa-refresh"></i>

The simple way to reverse your animation is to reverse the direction of its CSS property called animation-direction.
animation-direction: reverse;

You can also solve the problem without additional CSS.
The outer <i> flips the inner <i> first. The inner <i> spins. See here:
<i class="fa fa-flip-vertical">
<i class="fa fa-spin fa-refresh"></i>
</i>

Related

How to make the animation continue even if not hovering

When i'm hovering an img, i want it to rotate. My problem is when i hover the img it rotates but if i stop hovering it, it just goes to how it was initially, it doesn't continue the animation... I want the img to rotate when hovering it and continue even if i mouve the mouse out of the img. Also no JS please, I only want to use CSS
ps: Sorry for my bad english, I'm french :P
0% {-webkit-transform: rotate(0deg);}
100% {-webkit-transform: rotate(360deg);}
}
img:hover{
animation-name: Animation;
animation-duration: 1s;
}
This will work:
#keyframes rotation {
from {
-ms-transform: rotate(0deg);
-moz-transform: rotate(0deg);
-webkit-transform: rotate(0deg);
-o-transform: rotate(0deg);
transform: rotate(0deg);
}
to {
-ms-transform: rotate(360deg);
-moz-transform: rotate(360deg);
-webkit-transform: rotate(360deg);
-o-transform: rotate(360deg);
transform: rotate(360deg);
}
}
img:hover{
-moz-animation: rotation .6s infinite linear;
-moz-border-radius: 100%;
-o-animation: rotation .6s infinite linear;
-webkit-animation: rotation .6s infinite linear;
-webkit-border-radius: 100%;
animation: rotation .6s infinite linear;
}
<img src="https://www.gravatar.com/avatar/1ebceb30742d4815e63f649cbb853834?s=32&d=identicon&r=PG&f=1">

Animation in mozilla doesn't work properly

I didn't asked about transform origin. I asked why the animation doesn't work on mozilla
I'm stuck doing some animation svg on Mozilla. What I have tried in Chrome the animation worked perfectly fine, but when I tested on mozilla it's doesn't work well. I have put the vendor prefix, still the animation doesn't work properly.
I can't share the svg because the line of code to share here is limited, So please check it out from the demo.
Here is the DEMO
CSS
.trans-animate {
-webkit-transform: translate(-24%,9%);
transform: translate(-24%,9%);
-webkit-animation: wavedash 6s ease-out infinite;
animation: wavedash 6s ease-out infinite;
}
#-webkit-keyframes wavedash {
0% {
-webkit-transform: translate(-28%,9%);
transform: translate(-28%,9%);
}
50% {
-webkit-transform: translate(-42%,9%);
transform: translate(-42%,9%);
}
100% {
-webkit-transform: translate(-20%,9%);
transform: translate(-20%,9%);
}
}
.trans-animate2 {
-webkit-transform: translate(-38%,2%);
transform: translate(-38%,2%);
-webkit-animation: wavedash2 10s ease-out infinite;
animation: wavedash2 10s ease-out infinite;
}
#-webkit-keyframes wavedash2 {
0% {
-webkit-transform: translate(-28%,2%);
transform: translate(-28%,2%);
}
50% {
-webkit-transform: translate(-5%,2%);
transform: translate(-5%,2%);
}
100% {
-webkit-transform: translate(8%,2%);
transform: translate(8%,2%);
}
}
.dolphin-loca {
/*transform: translate(-166%,69%);*/
-webkit-animation: dolphin 8s ease-out infinite;
animation: dolphin 8s ease-out infinite;
}
#-webkit-keyframes dolphin {
0% {
-webkit-transform: translate(-172%,40%);
transform: translate(-172%,40%);
}
50% {
-webkit-transform: translate(-172%, -36%);
transform: translate(-172%, -36%);
}
65% {
-webkit-transform: translate(-172%, -36%);
transform: translate(-172%, -36%);
}
80% {
-webkit-transform: translate(-172%, -36%);
transform: translate(-172%, -36%);
}
100% {
-webkit-transform: translate(-172%,40%);
transform: translate(-172%,40%);
}
}
.text-dolphin {
-webkit-animation: dolphin-button 8s ease-out infinite;
animation: dolphin-button 8s ease-out infinite;
}
#-webkit-keyframes dolphin-button {
0% {
-webkit-transform: translate(-172%,40%);
transform: translate(-172%,40%);
opacity: 0;
}
50% {
-webkit-transform: translate(-123%, -60%);
transform: translate(-123%, -60%);
opacity: 0;
}
65% {
-webkit-transform: translate(-123%, -60%);
transform: translate(-123%, -60%);
opacity: 1;
}
78% {
-webkit-transform: translate(-123%, -60%);
transform: translate(-123%, -60%);
opacity: 1;
}
85% {
-webkit-transform: translate(-162%, -60%);
transform: translate(-162%, -60%);
opacity: 0;
}
100% {
-webkit-transform: translate(-172%,40%);
transform: translate(-172%,40%);
opacity: 0;
}
}
.closeEye {
-webkit-animation: eye 1.5s cubic-bezier(.17,.67,.48,.84) infinite;
animation: eye 1.5s cubic-bezier(.17,.67,.48,.84) infinite;
}
#-webkit-keyframes eye {
0% {
-webkit-transform: translateY(0px) scaleY(1);
transform: translateY(0px) scaleY(1);
}
10% {
-webkit-transform: translateY(265px) scaleY(0.05);
transform: translateY(265px) scaleY(0.05);
}
15% {
-webkit-transform: translateY(170px) scaleY(0.4);
transform: translateY(170px) scaleY(0.4);
}
25% {
-webkit-transform: translateY(85px) scaleY(0.7);
transform: translateY(85px) scaleY(0.7);
}
30% {
-webkit-transform: translateY(85px) scaleY(0.7);
transform: translateY(85px) scaleY(0.7);
}
35% {
-webkit-transform: translateY(170px) scaleY(0.4);
transform: translateY(170px) scaleY(0.4);
}
40% {
-webkit-transform: translateY(255px) scaleY(0.1);
transform: translateY(255px) scaleY(0.1);
}
100% {
-webkit-transform: translateY(0px) scaleY(1);
transform: translateY(0px) scaleY(1);
}
}
There are two reasons your animation doesn't work on Firefox.
The primary reason is that you have #-webkit-keyframes rules, which work in Chrome, but you have no #keyframes rules, which Firefox needs. You need to include both variants.
The second reason is related to the transform-origin difference between Firefox and Chrome.
Percentages in SVG files are relative to the viewport size (the dimensions of the SVG). That's what Firefox does. So translate(-172%,40%) is putting the dolphin way off the edge of the SVG.
Chrome is calculating percentages relative to the dimensions of the dolphin. That is not the correct behaviour.
If you want your animation to work in both browsers, you need to switch to using absolute pixel values in your transform rules (eg. 100px).
.dolphin-loca {
-webkit-animation: dolphin 8s ease-out infinite;
animation: dolphin 8s ease-out infinite;
}
#-webkit-keyframes dolphin {
0% {
transform: translate(-300px, 100px);
}
50% {
transform: translate(-300px, -100px);
}
65% {
transform: translate(-300px, -100px);
}
80% {
transform: translate(-300px, -100px);
}
100% {
transform: translate(-300px, 100px);
}
}
#keyframes dolphin {
0% {
transform: translate(-300px, 100px);
}
50% {
transform: translate(-300px, -100px);
}
65% {
transform: translate(-300px, -100px);
}
80% {
transform: translate(-300px, -100px);
}
100% {
transform: translate(-300px, 100px);
}
}
<svg x="0px" y="0px" width="1600px" height="450.39px" viewBox="0 0 1600 450.39">
<g id="Layer_7" class="dolphin-loca" >
<path id="XMLID_29_" fill="#0083B7" d="M805.419,255.439c0-44.307-28.647-75.028-71.876-79.144 c1.21-4.736,2.37-7.935-2.083-7.935c-3.665,0-8.222,3.306-11.537,7.72c-44.529,2.807-74.611,34.122-74.611,79.359 c0,12.658,2.772,23.054,7.724,31.504c-4.966,9.543-5.992,22.504-1.546,28.282c5.617,7.3,8.705-3.645,17.415-11.529 c15.167,10.519,32.232,14.748,56.46,14.748c2.102,0,4.185-0.033,6.248-0.098c-0.163,6.328-2.354,13.155-7.468,20.396 c-3.842-5.743-20.614-27.065-47.537-8.519c-1.583,1.09,17.322,28.912,44.758,12.288c-0.328,0.717-0.755,2.152,1.434,1.581 c-4.001,6.03-9.983,19.613,5.826,32.179c1.107,0.88,16.966-18.865-2.171-34.437c5.641-3.797,16.995-12.42,26.062-25.462 c13.228-2.205,20.431-6.272,29.324-12.662c8.699,7.883,11.786,18.811,17.4,11.515c4.446-5.778,3.42-18.739-1.546-28.282 C802.648,278.493,805.419,268.097,805.419,255.439z M725.366,314.436c-44.229,0-74.917-14.978-74.917-59.207 s30.688-74.401,74.917-74.401c44.229,0,74.917,30.172,74.917,74.401S769.595,314.436,725.366,314.436z" />
</g>
</svg>

How to set loop and behavior for marquee in my custom css?

I'm creating a custom marquee for my application.. I want to text animation run only 1 time and stop completely. My code is running repeat after 20s and never stop. I tried replace infinite by "1" ( loop ) and behavior="scroll" but it doesn't work. How to implement it?
html
<li class="marquee" ng-show="notification_message">
<a href="#">
message
</a
</li>
css
#keyframes left-one {
0% {
transform: translateX(100%);
}
10% {
transform: translateX(0);
}
40% {
transform: translateX(0);
}
50% {
transform: translateX(-100%);
}
100% {
transform: translateX(-100%);
}
}
#keyframes left-two {
0% {
transform: translateX(100%);
}
50% {
transform: translateX(100%);
}
60% {
transform: translateX(0);
}
90% {
transform: translateX(0);
}
100% {
transform: translateX(-100%);
}
}
.marquee a:nth-child(1) {
animation: left-one 20s ease infinite;
}
.marquee a:nth-child(2) {
animation: left-two 20s ease infinite;
}

CSS transition interferes with animation

I have this css :
.yellowText {
color: #FFFF00;
-ms-transform: rotate(-20deg); /* IE 9 */
-webkit-transform: rotate(-20deg); /* Chrome, Safari, Opera */
transform: rotate(-20deg);
}
.pulse {
-webkit-animation: text-anim;
animation: text-anim 1s;
-webkit-animation-duration: 1s;
animation-duration: 1s;
-webkit-animation-fill-mode: both;
animation-fill-mode: both;
-webkit-animation-timing-function: ease-in-out;
animation-timing-function: ease-in-out;
animation-iteration-count:infinite;
-webkit-animation-iteration-count:infinite;
}
#-webkit-keyframes text-anim {
0% { -webkit-transform: scale(1); }
50% { -webkit-transform: scale(1.1); }
100% { -webkit-transform: scale(1); }
}
#keyframes text-anim {
0% { transform: scale(1); }
50% { transform: scale(1.1); }
100% { transform: scale(1); }
}
Then, I apply it to a text :
<p class="yellowText pulse">Some text here</p>
But now, the text is well-animated, without being rotated by -20°... Any idea of what could be wrong ? I believe this is a problem with the transform property not working with the animation one. Also, what I tried was putting the transform inside the #keyframes text-anim, but what this does is just periodically rotating the text, having it perfectly right the rest of the time...
Thanks in advance for your help !
PS : forgive my bad English, I'm French :P
Your #keyframes are overriding you original transform property.
#-webkit-keyframes text-anim {
0% { -webkit-transform: scale(1 rotate(-20deg); }
50% { -webkit-transform: scale(1.1) rotate(-20deg); }
100% { -webkit-transform: scale(1) rotate(-20deg); }
}
#keyframes text-anim {
0% { transform: scale(1) rotate(-20deg); }
50% { transform: scale(1.1) rotate(-20deg); }
100% { transform: scale(1) rotate(-20deg); }
}

CSS3 animation strange behaviour in chrome

I am trying to create a CSS3 animation which rotates a div with image in background.
On hover I want to use the same animation with different speed.
This is the code I'm using for achieving it:
.rocket{
background: url('http://thumbs.ebaystatic.com/d/l96/m/mR3-h7oYVSGGYNTBiKJbtMQ.jpg') no-repeat center;
width: 200px;
height: 200px;
-webkit-animation : spin 1500ms linear infinite;
animation : spin 1500ms linear infinite;
}
.rocket:hover{
-webkit-animation : spin 500ms linear infinite;
animation : spin 500ms linear infinite;
}
#-webkit-keyframes spin{
from{
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
}
to{
-webkit-transform: rotate(360deg);
transform: rotate(360deg);
}
}
#keyframes spin{
from{
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
}
to{
-webkit-transform: rotate(360deg);
transform: rotate(360deg);
}
<div class="rocket"></div>
But to my surprise the hover animation works only in firefox and not in chrome.
For a temporary fix I created one more animation for hover with different name and it works fine:
.rocket{
background: url('http://thumbs.ebaystatic.com/d/l96/m/mR3-h7oYVSGGYNTBiKJbtMQ.jpg') no-repeat center;
width: 200px;
height: 200px;
-webkit-animation : spin 1500ms linear infinite;
animation : spin 1500ms linear infinite;
}
#-webkit-keyframes spin{
from{
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
}
to{
-webkit-transform: rotate(360deg);
transform: rotate(360deg);
}
}
#keyframes spin{
from{
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
}
to{
-webkit-transform: rotate(360deg);
transform: rotate(360deg);
}
}
.rocket:hover{
-webkit-animation : spin2 500ms linear infinite;
animation : spin2 500ms linear infinite;
}
#-webkit-keyframes spin2{
from{
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
}
to{
-webkit-transform: rotate(360deg);
transform: rotate(360deg);
}
}
#keyframes spin2{
from{
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
}
to{
-webkit-transform: rotate(360deg);
transform: rotate(360deg);
}
}
Can you tell me why this is happening and how I can use the same animation with hover in chrome?
FIDDLE
This is a browser bug that is related to chrome there has been an issue filed to fix it. So your best bet is to find a work around for the bug which you seem to have already done so until the browser bug is fixed just keep using your workaround.