【问题标题】:CSS3 animation transform rotate not working in FirefoxCSS3动画变换旋转在Firefox中不起作用
【发布时间】:2016-02-05 19:14:41
【问题描述】:

我在 codepen.io 中找到了这个动画。一切正常,但是当我在 Firefox 中对其进行测试时,动画无法正常工作。

代码已经有浏览器前缀,所以我不知道什么在 FF 中不起作用。

<!DOCTYPE html>
<html>
<head>
<style> 

.loading {
    margin-left:auto;
    margin-right:auto;
    display:table;
    border-width:30px;
    border-radius:50%;
    -webkit-animation:spin 1s linear infinite;
    -moz-animation:spin 1s linear infinite;
    -o-animation:spin 1s linear infinite;
    animation:spin 1s linear infinite;
}
.style-1 {
    border-style:solid;
    border-color:#001e60 transparent
}
.style-2 {
    border-style:double;
    border-color:#001e60 transparent;
}
.style-3 {
    border-style:double;
    border-color:#001e60 #fff #fff;
}
@-webkit-keyframes spin {
    100% {
        -webkit-transform:rotate(359deg);
    }
}
@-moz-keyframes spin {
    100% {
        -moz-transform:rotate(359deg);
    }
}
@-o-keyframes spin {
    100% {
        -moz-transform:rotate(359deg);
    }
}
@keyframes spin {
    100% {
        transform:rotate(359deg);
    }
}
</style>
</head>
<body>

<div style="display: block;" class="loading-container">
        <span id="loadingIndicator" class="loading style-3"></span>
    </div>

</body>
</html>

【问题讨论】:

    标签: html css css-transitions


    【解决方案1】:

    问题在于 .loading 使用 display: table; 时没有实际指定宽度或高度。使用这样的表格来暗示大小有点 hacky。 Chrome 对这些维度的解释与 Firefox 不同。最好使用 css 明确地给它一个大小。尝试将其更改为具有如下宽度和高度的块:

    .loading {
      margin-left:auto;
      margin-right:auto;
      display:block;
      border-width:30px;
      border-radius:50%;
      height: 5px;
      width: 5px;
      -webkit-animation:spin 1s linear infinite;
      -moz-animation:spin 1s linear infinite;
      -o-animation:spin 1s linear infinite;
      animation:spin 1s linear infinite;
    }
    

    BIN:https://jsbin.com/nedanayopu/edit?html,output

    【讨论】:

      猜你喜欢
      • 2015-03-05
      • 1970-01-01
      • 1970-01-01
      • 2014-03-09
      • 1970-01-01
      • 2014-07-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多