【发布时间】:2018-12-12 06:34:28
【问题描述】:
我想不通这个...我不能真正在项目中添加标记,只能添加 CSS(出于许多无聊的原因,与我远程协作的人)。
最终客户希望他们的徽标路径被绘制但不是线性的加载动画,更轻松(慢 - 快 - 慢)之类的东西。为了说明我的意思,请参阅我所做的 jsfiddle:https://jsfiddle.net/tobzzzz/djf7oth2/(他们的徽标有点像语音标记,我为演示做了一个圆圈)。
徽标将位于图像背景之上,而不是白色/纯色背景,因此我的小提琴解决方案不适用于两个分层的圆圈。我添加了浅灰色背景来演示它是如何不起作用的。
理想的解决方案是仅使用 SVG(使用 SVG 动画而不是 CSS 动画),然后我会将其转换为数据并将其作为背景图像。
如果仅使用 SVG 动画无法完成,我想知道是否可以使用 SVG 和 CSS 组合来完成。但绝对100%不可能是JS。
有什么好主意吗?
body {
background: #eee
}
.black {
stroke-dasharray: 350;
stroke-dashoffset: 350;
animation: dash 4s linear infinite;
}
.white {
stroke-dasharray: 350;
stroke-dashoffset: 350;
animation: dash2 4s ease-in-out infinite;
}
@keyframes dash {
80% {
stroke-dashoffset: 0;
}
}
@keyframes dash2 {
100% {
stroke-dashoffset: 0;
}
}
<svg class="path" width="84" height="84" xmlns="http://www.w3.org/2000/svg">
<path class="black" fill="none" stroke="#000000" stroke-width="4" d="M 80.889194,41.80541 C 80.889194,63.45198 63.341174,81 41.694594,81 20.048024,81 2.5,63.45198 2.5,41.80541 2.5,20.158827 20.048024,2.61081 41.694594,2.61081 c 21.64658,0 39.1946,17.548017 39.1946,39.1946 z"/>
<path class="white" fill="none" stroke="white" stroke-width="5" d="M 80.889194,41.80541 C 80.889194,63.45198 63.341174,81 41.694594,81 20.048024,81 2.5,63.45198 2.5,41.80541 2.5,20.158827 20.048024,2.61081 41.694594,2.61081 c 21.64658,0 39.1946,17.548017 39.1946,39.1946 z"/>
</svg>
【问题讨论】: