css - Firefox 中的 CSS 动画不流畅
问题描述
我有这个简单的加载指示器
https://jsfiddle.net/tcdLj0f9/
body {
background: #1e263e;
}
.load {
display: flex;
position: fixed;
align-items: center;
justify-content: center;
height: 100%;
width: 100%;
}
.loadersp {
border: 12px solid #f3f3f3;
border-top: 12px solid #555!important;
border-radius: 50%;
width: 96px;
height:96px;
animation: sp-rotate 2s linear infinite;
}
@keyframes sp-rotate {
0% {
transform: rotate(0deg)
}
to {
transform: rotate(1turn)
}
}
<div class="load">
<div class="loadersp"></div>
</div>
它在 Chrome 中运行顺畅,而在 Firefox 中则无法运行(使用最新版本).. 即使看着微调器的边缘,你也可以看到它们很粗糙,为什么会这样?我知道他们使用不同的渲染引擎,但我没想到会发生这样的事情。
那么有没有办法解决呢?
解决方案
这看起来像一个 Firefox 错误。
如果您在position:fixed
容器中使用动画iframe
(如 jsfiddle 或 SO 片段),它会在 Firefox 中运行不稳定。从iframe
它的工作顺利。
删除position:fixed
修复它iframe
:
body {
background: #1e263e;
}
.load {
display: flex;
/* position: fixed; */
align-items: center;
justify-content: center;
height: 100%;
width: 100%;
}
.loadersp {
border: 12px solid #f3f3f3;
border-top: 12px solid #555 !important;
border-radius: 50%;
width: 96px;
height: 96px;
animation: sp-rotate 2s linear infinite;
}
@keyframes sp-rotate {
0% {
transform: rotate(0deg)
}
to {
transform: rotate(1turn)
}
}
<div class="load">
<div class="loadersp"></div>
</div>
推荐阅读
- php - 如何使用 preg_match 获取 URL 的特殊部分?
- amazon-cloudfront - 如何更改查看器响应 Cloudfront 事件中的状态代码?
- python - 为什么我收到“没有名为 OpenAI 的模块”导入错误?
- xpath - 如何使用 XQuery 检测具有多个节点的重复子节点
- linux - bash 脚本来获取脚本的 asbolute 目录
- angular - 角度选择对象索引
- .htaccess - .htaccess - 删除 url 的结尾部分
- linux - Golang rest api 和 curl
- c++ - 反转后如何让字符串按顺序打印
- angular - 来自“any”的变量赋值返回不正确的数据类型