html - stroke-dashoffset 动画在 Safari 中不起作用
问题描述
我正在为我的网站制作一个 CSS3 动画,其中stroke-dashoffset
SVG 是动画的。它适用于 Chrome 和 Opera,但不适用于 Safari 或 Firefox。在 Safari 上,文本显示但没有动画。在 Firefox 上,文本根本不显示。让 Safari 正常工作对我来说是最重要的,这样它才能在 iOS 上正确显示。
我已经尝试了很多东西,包括更改单位,使用百分比关键帧而不是to
and from
,添加和删除前缀,不使用动画属性的简写,更改各种属性,尝试不同的 webkit 前缀,仔细检查我不是stroke-dashoffset
使用负数等制作动画,到目前为止没有任何效果。我已经查看了我可以在网上找到的每篇文章,但没有找到解决方案。我希望我忽略了一些简单的事情,或者有一个简单的解决方法,但我担心这是一个 webkit 错误。
我在下面放了一个 JSfiddle,它在 Safari 和 Firefox 中复制了该问题,并在 Chrome 中正常工作: https ://jsfiddle.net/lystroid/2a97ntf1/58/
这是相关的 HTML 和 CSS:
HTML
<svg width="80vw" height="150vw">
<text y = "500px" fill="none" stroke="#e2e2e2" stroke-width="0.5">ABCDE</text>
</svg>
CSS
text {
font-family:arial;
text-align: center;
color: #e2e2e2;
font-size: 23vw;
line-height: 0;
stroke-dasharray: 98vw;
stroke-dashoffset: 98vw;
animation: draw 7s ease 1 forwards;
-webkit-animation: draw 7s ease 1 forwards;
-moz-animation: draw 7s ease 1 forwards;
-webkit-animation: draw 7s ease 1 forwards;
-o-animation: draw 7s ease 1 forwards;
-ms-animation: draw 7s ease 1 forwards;
}
@-webkit-keyframes draw {
from {
stroke-dashoffset: 98vw;
}
to {
stroke-dashoffset: 0vw;
}
}
@keyframes draw {
from {
stroke-dashoffset: 98vw;
}
to {
stroke-dashoffset: 0vw;
}
}
我没有在 Internet Explorer 或 Edge 中测试过动画。
谢谢阅读!
编辑:我应该澄清页面上有两个动画。其中之一是标题,它适用于所有浏览器。我在这个问题中所指的动画是 SVG 文本上的动画,上面写着“ABCDE”
解决方案
推荐阅读
- arrays - Julia 中的分布式 3 维数组
- javascript - 如何使我的绝对定位元素响应?
- merge - PDF 文件到相应的文件夹
- sql - 选择其中一个重复行并将其他行保持为 NULL SQL Netezza
- azure-pipelines-build-task - 如何创建到我的本地服务的服务连接?
- tensorflow - 没有 Eager 模式的 Tensorflow 提前编译?
- asp.net-web-api - 中介者模式——在控制器中还是在应用程序服务中?[asp.net 网络接口]
- sql - 如何在选择语句中选择结果作为子查询,大小写从 int 到 string
- aws-lambda - 无服务器部署失败:至少需要 ProvisionedThroughput、... 之一
- powerbi - Sportfire 到 Power BI 图表