Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS Animation works in Chrome, but not in FireFox

I have the following code in http://jsfiddle.net/4LPSD/

It works in Chrome(version 35.0.1916.153), but not in Firefox(version 30.0).

/******** HTM **********************/
<div class="container">
     <h3>Animated button</h3>
     <button class="btn btn-lg btn-warning"><span class="glyphicon glyphicon-refresh     glyphicon-refresh-animate"></span> Loading...</button>
</div>


/******* CSS **********************/
/* Latest compiled and minified CSS included as External Resource*/

/* Optional theme */
@import url('http://getbootstrap.com/dist/css/bootstrap.css');

.glyphicon-refresh-animate {
    -animation: spin .7s infinite linear;
    -webkit-animation: spin2 .7s infinite linear;
}

@-webkit-keyframes spin2 {
    from { -webkit-transform: rotate(0deg);}
    to { -webkit-transform: rotate(360deg);}
}

@keyframes spin {
    from { transform: scale(1) rotate(0deg);}
    to { transform: scale(1) rotate(360deg);}
}

Anybody knows whats wrong?

I'm trying to rotate a picture icon.

like image 259
Fernando_Jr Avatar asked Dec 26 '22 07:12

Fernando_Jr


2 Answers

You need to include the Mozilla prefix, and remove the hyphen before animation:

.glyphicon-refresh-animate {
  animation: spin .7s infinite linear;
  -webkit-animation: spin2 .7s infinite linear;
  -moz-animation: spin2 .7s infinite linear;
}

@-moz-keyframes spin2 {
  from { -moz-transform: rotate(0deg);}
  to { -moz-transform: rotate(360deg);}
}
like image 133
Robert Messerle Avatar answered Dec 27 '22 20:12

Robert Messerle


Thanks for your answers.

I use the parameter -moz and remove the caracter "-" of -animation

This is final code:

/*********** HTML *********************/

<div class="container">
     <h3>Animated button</h3>
    <button class="btn btn-lg btn-warning">
        <span class="glyphicon glyphicon-refresh glyphicon-refresh-animate"></span>
        Loading...
    </button>
</div>

/*********** CSS *********************/

/* Latest compiled and minified CSS included as External Resource*/

/* Optional theme */
@import url('http://getbootstrap.com/dist/css/bootstrap.css');

.glyphicon-refresh-animate {
    -moz-animation: spin-moz .7s infinite linear;
    -webkit-animation: spin-webkit .7s infinite linear;
    animation: spin .7s infinite linear;
}

@-moz-keyframes spin-moz {
  from { -moz-transform: rotate(0deg);}
  to { -moz-transform: rotate(360deg);}
}

@-webkit-keyframes spin-webkit {
    from { -webkit-transform: rotate(0deg);}
    to { -webkit-transform: rotate(360deg);}
}

@keyframes spin {
    from { transform: scale(1) rotate(0deg);}
    to { transform: scale(1) rotate(360deg);}
}
like image 28
Fernando_Jr Avatar answered Dec 27 '22 20:12

Fernando_Jr