Css动画在Google Chrome中不起作用?

时间:2014-12-11 13:26:08

标签: html5 css3 animation

我有一些css动画来自微调器,但我不能让它在谷歌Chrome中工作,我已经阅读了很多帖子并发现我缺少WebKit浏览器的关键帧规则,但我不知道如何制作它

这是我的css和html

@keyframes spin {
    to { transform: rotate(1turn); }
}

.progress-loading {
    position: relative;
    display: inline-block;
    width: 5em;
    height: 5em;
    margin: 0 .5em;
    font-size: 12px;
    text-indent: 999em;
    overflow: hidden;
    animation: spin 1s infinite steps(8);
}

.small.progress-loading {
    font-size: 6px;
}

.large.progress-loading {
    font-size: 24px;
}

.progress-loading:before,
.progress-loading:after,
.progress-loading > div:before,
.progress-loading > div:after {
    content: '';
    position: absolute;
    top: 0;
    left: 2.25em; /* (container width - part width)/2  */
    width: .5em;
    height: 1.5em;
    border-radius: .2em;
    background: #eee;
    box-shadow: 0 3.5em #eee; /* container height - part height */
    transform-origin: 50% 2.5em; /* container height / 2 */
}

.progress-loading:before {
    background: #555;
}

.progress-loading:after {
    transform: rotate(-45deg);
    background: #777;
}

.progress-loading > div:before {
    transform: rotate(-90deg);
    background: #999;
}

.progress-loading > div:after {
    transform: rotate(-135deg);
    background: #bbb;
}

HTML

<div class="small progress-loading"><div>Loading…</div></div>

并且工作小提琴,请在铬中chek它不起作用:( http://fiddle.jshell.net/ynoLjs1c/3/

1 个答案:

答案 0 :(得分:1)

您缺少-webkit-前缀。请务必核对browser support

&#13;
&#13;
@keyframes spin {
  to {
    transform: rotate(1turn);
  }
}
@-webkit-keyframes spin {
  to {
    -webkit-transform: rotate(1turn);
    transform: rotate(1turn);
  }
}
.progress-loading {
  position: relative;
  display: inline-block;
  width: 5em;
  height: 5em;
  margin: 0 .5em;
  font-size: 12px;
  text-indent: 999em;
  overflow: hidden;
  -webkit-animation: spin 1s infinite steps(8);
  animation: spin 1s infinite steps(8);
}
.small.progress-loading {
  font-size: 6px;
}
.large.progress-loading {
  font-size: 24px;
}
.progress-loading:before,
.progress-loading:after,
.progress-loading > div:before,
.progress-loading > div:after {
  content: '';
  position: absolute;
  top: 0;
  left: 2.25em;
  /* (container width - part width)/2  */
  width: .5em;
  height: 1.5em;
  border-radius: .2em;
  background: #eee;
  box-shadow: 0 3.5em #eee;
  /* container height - part height */
  transform-origin: 50% 2.5em;
  /* container height / 2 */
}
.progress-loading:before {
  background: #555;
}
.progress-loading:after {
  transform: rotate(-45deg);
  background: #777;
}
.progress-loading > div:before {
  transform: rotate(-90deg);
  background: #999;
}
.progress-loading > div:after {
  transform: rotate(-135deg);
  background: #bbb;
}
&#13;
<div class="small progress-loading">
  <div>Loading…</div>
</div>
&#13;
&#13;
&#13;