简体   繁体   中英

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.

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);}
}

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);}
}

As Niet the Dark Absol already said, you have to remove the dash before -animation and it will work. See the updated fiddle

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM