html - CSS Animation 仅适用于 Firefox 和 Chrome,但不适用于 Apple 设备(Safari?)
问题描述
我制作了一些动画计数,它们在 Firefox 和 Chrome 浏览器中运行良好,但在 Apple 设备的默认浏览器(Safari?)中却不行:
div::after {
font: 800 40px system-ui;
content: counter(count);
animation: counter 5s linear forwards;
counter-reset: count 0;
}
@keyframes counter {
0% { counter-increment: count 0; }
10% { counter-increment: count 8; }
20% { counter-increment: count 16; }
30% { counter-increment: count 32; }
40% { counter-increment: count 64; }
50% { counter-increment: count 128; }
60% { counter-increment: count 256; }
70% { counter-increment: count 512; }
80% { counter-increment: count 1024; }
90% { counter-increment: count 2048; }
100% { counter-increment: count 4000; }
}
<div></div>
我怎样才能在 Apple 设备上也能做到这一点?
也许添加一些-webkit-animation
或@-webkit-keyframes
某处?
解决方案
用于webkits
您的关键帧:
@-webkit-keyframes counter {
0% { -webkit-counter-increment: count 0; }
10% { -webkit-counter-increment: count 8; }
20% { -webkit-counter-increment: count 16; }
30% { -webkit-counter-increment: count 32; }
40% { -webkit-counter-increment: count 64; }
50% { -webkit-counter-increment: count 128; }
60% { -webkit-counter-increment: count 256; }
70% { -webkit-counter-increment: count 512; }
80% { -webkit-counter-increment: count 1024; }
90% { -webkit-counter-increment: count 2048; }
100% { -webkit-counter-increment: count 4000; }
}
@keyframes counter {
0% { counter-increment: count 0; }
10% { counter-increment: count 8; }
20% { counter-increment: count 16; }
30% { counter-increment: count 32; }
40% { counter-increment: count 64; }
50% { counter-increment: count 128; }
60% { counter-increment: count 256; }
70% { counter-increment: count 512; }
80% { counter-increment: count 1024; }
90% { counter-increment: count 2048; }
100% { counter-increment: count 4000; }
}
div::after {
font: 800 40px system-ui;
content: counter(count);
animation: counter 5s linear forwards;
counter-reset: count 0;
}
<div></div>
也看看CanIUse
推荐阅读
- java - Gradle 不在命令行上执行任何测试
- javascript - 如何正确地将源地图上传到带有客户端和服务器部分的项目的哨兵?
- javascript - 当键有空格和点时如何在mongodb中查询
- c# - 放大一定距离
- excel - 返回共享邮箱的存档邮件的单个发件人
- google-chrome - 有没有办法检测在 iframe 中单击的链接,而不是打开新选项卡,而是将 iframe src 更改为该链接?
- haskell - 读取每个文件的第一行在二进制文件中被中止
- c++ - 如何在没有memcpy的情况下将结构数组分配给类变量
- ios - 由于 iOS 13 不支持 3D Touch,是否有任何功能可以通过长按手势打开预览(预览)?
- c# - 我可以写我的运动脚本速记吗?