【发布时间】:2021-10-29 00:12:35
【问题描述】:
我制作了一些动画计数,在 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?
【问题讨论】:
-
这能回答你的问题吗? CSS3 animation not working in safari
-
是的,你没看错。您必须使用 webkit 前缀更新样式。您可以检查浏览器兼容性here
-
@JackBennett:感谢您的评论!不幸的是,链接的答案没有帮助,因为我已经使用了高达 100% 的百分比。
-
@Ms.Tamil:感谢您的评论!所以我必须双插入所有代码,包括
-webkit-prefixes? -
看来我错过了那个答案,抱歉。不过,我同意 Tamil 女士的另一条评论 - 检查浏览器兼容性并确保您的代码以这种方式与 safari 一起使用。
标签: html css ios browser css-animations