css - CSS中的多个动画 - 仅重复秒动画
问题描述
我想并行运行两个动画,而第二个动画的延迟为 1s。
下面的代码在初始迭代中完美运行,然而,第一个动画dash01
只执行一次,尽管我将它设置为无限运行。
#Vector_42 {
stroke-dasharray: 5;
animation-name: dash01, dash01Rev;
animation-duration: 5s, 5s;
animation-delay: 0s, 1s;
animation-iteration-count: infinite, infinite;
animation-timing-function: linear, linear;
animation-direction: forwards, forwards;
}
@keyframes dash01 {
0% { stroke: #0066cc; stroke-dashoffset: 5; }
10%, 100% { stroke-dashoffset: 15; }
}
@keyframes dash01Rev {
0% { stroke: #0066cc; stroke-dashoffset: -5; }
10%, 100% { stroke-dashoffset: -15; }
}
有什么想法我在这里做错了吗?
解决方案
感谢@Temani Afif 的建议:
只需在一个动画中完成所有操作。您需要计算或估计 1 秒的延迟是多少并以这种方式实现:
@keyframes dash01{
0% { stroke: #0066cc; stroke-dashoffset: 5; } // Start going forward
10% { stroke-dashoffset: 15; } // Continue same way
10.1% { stroke-dashoffset: 15; } // Still continue
20% { stroke-dashoffset: 15; } // Still continue
20.1% { stroke-dashoffset: -5; } // Set reverse way
30% { stroke-dashoffset: -15; } // Go reverse now
100% { stroke-dashoffset: -15; } // Keep going reverse :D
}
推荐阅读
- python - 带有 requires_grad 参数的 torch.Tensor()
- google-cloud-platform - 关于 message.ack() 和 message.nack() 方法的文档在哪里?
- docker - 在特定目录中创建 docker 镜像
- makefile - 传递变量时抛出“找不到命令”
- c# - c#中1000,000格式的自定义数字组(千位分隔符)
- c# - 按类型查找控件的祖先
- c++ - C++ 异常处理:关于 'try' 块
- angular - 如何在选定对象的自动完成中仅显示特定对象属性而不是Angular 7中的[对象]
- python - Python cpppo 不会显示来自 PLC 的字符串数据类型
- arrays - Excel VBA:如何使用嵌套数组