html - 用于上传文件的五个不同图标的加载动画
问题描述
我有五个<svg>
标签,我应该将相同的动画附加到所有标签上,它们的不透明度在无限循环中从 1 变为 0。我希望动画显示上传文件的进度。任何帮助,将不胜感激。
<svg xmlns="http://www.w3.org/2000/svg" width="4" height="4" viewBox="0 0 4 4">
<g id="Group_1707" data-name="Group 1707" transform="translate(-331 -351)">
<path id="Path_3284" data-name="Path 3284" d="M2,0A2,2,0,1,1,0,2,2,2,0,0,1,2,0Z"
transform="translate(331 351)" fill="#8c8c8c"/>
</g>
</svg>
<svg xmlns="http://www.w3.org/2000/svg" width="4" height="4" viewBox="0 0 4 4">
<g id="Group_1707" data-name="Group 1707" transform="translate(-339 -351)">
<rect id="Rectangle_2599" data-name="Rectangle 2599" width="4" height="4" rx="2"
transform="translate(339 351)" fill="rgba(140,140,140,0.8)"/>
</g>
</svg>
<svg xmlns="http://www.w3.org/2000/svg" width="4" height="4" viewBox="0 0 4 4">
<g id="Group_1707" data-name="Group 1707" transform="translate(-347 -351)">
<rect id="Rectangle_2600" data-name="Rectangle 2600" width="4" height="4" rx="2"
transform="translate(347 351)" fill="rgba(140,140,140,0.6)"/>
</g>
</svg>
<svg xmlns="http://www.w3.org/2000/svg" width="4" height="4" viewBox="0 0 4 4">
<g id="Group_1707" data-name="Group 1707" transform="translate(-355 -351)">
<rect id="Rectangle_2601" data-name="Rectangle 2601" width="4" height="4" rx="2"
transform="translate(355 351)" fill="rgba(140,140,140,0.4)"/>
</g>
</svg>
<svg xmlns="http://www.w3.org/2000/svg" width="4" height="4" viewBox="0 0 4 4">
<g id="Group_1707" data-name="Group 1707" transform="translate(-363 -351)">
<rect id="Rectangle_2602" data-name="Rectangle 2602" width="4" height="4" rx="2"
transform="translate(363 351)" fill="rgba(140,140,140,0.2)"/>
</g>
</svg>
解决方案
@keyframes
动画和animation-delay
@keyframes loading{
0%{
opacity:1;
}
50%{
opacity:0;
}
}
svg{
animation:loading 1s infinite;
}
svg:nth-of-type(1){
animation-delay:0.2s;
}
svg:nth-of-type(2){
animation-delay:0.4s;
}
svg:nth-of-type(3){
animation-delay:0.6s;
}
svg:nth-of-type(4){
animation-delay:0.8s;
}
svg:nth-of-type(5){
animation-delay:1s;
}
<svg xmlns="http://www.w3.org/2000/svg" width="4" height="4" viewBox="0 0 4 4">
<g id="Group_1707" data-name="Group 1707" transform="translate(-331 -351)">
<path id="Path_3284" data-name="Path 3284" d="M2,0A2,2,0,1,1,0,2,2,2,0,0,1,2,0Z"
transform="translate(331 351)" fill="#8c8c8c"/>
</g>
</svg>
<svg xmlns="http://www.w3.org/2000/svg" width="4" height="4" viewBox="0 0 4 4">
<g id="Group_1707" data-name="Group 1707" transform="translate(-339 -351)">
<rect id="Rectangle_2599" data-name="Rectangle 2599" width="4" height="4" rx="2"
transform="translate(339 351)" fill="rgba(140,140,140,0.8)"/>
</g>
</svg>
<svg xmlns="http://www.w3.org/2000/svg" width="4" height="4" viewBox="0 0 4 4">
<g id="Group_1707" data-name="Group 1707" transform="translate(-347 -351)">
<rect id="Rectangle_2600" data-name="Rectangle 2600" width="4" height="4" rx="2"
transform="translate(347 351)" fill="rgba(140,140,140,0.6)"/>
</g>
</svg>
<svg xmlns="http://www.w3.org/2000/svg" width="4" height="4" viewBox="0 0 4 4">
<g id="Group_1707" data-name="Group 1707" transform="translate(-355 -351)">
<rect id="Rectangle_2601" data-name="Rectangle 2601" width="4" height="4" rx="2"
transform="translate(355 351)" fill="rgba(140,140,140,0.4)"/>
</g>
</svg>
<svg xmlns="http://www.w3.org/2000/svg" width="4" height="4" viewBox="0 0 4 4">
<g id="Group_1707" data-name="Group 1707" transform="translate(-363 -351)">
<rect id="Rectangle_2602" data-name="Rectangle 2602" width="4" height="4" rx="2"
transform="translate(363 351)" fill="rgba(140,140,140,0.2)"/>
</g>
</svg>
推荐阅读
- python - inplace ==False 是创建副本还是引用相同的数据集?
- c# - 如何在嵌套操作方法调用 WebApi 中从验证中跳过自定义属性
- javascript - 定义全局常量时JS未定义导入(未定义错误)
- android - 为什么从 Android Studio 3.5 的 Configure Vector Asset 中删除了 Override 选项?
- teradata - 预期在“别名”一词和“ON”关键字之间有一些内容
- heroku - Heroku 进程绑定端口失败
- excel - 接收应用程序为此公式定义的错误
- php - 我想使用删除路由,但不支持。我怎样才能使用这条路线?
- css - 如何为伪元素添加边框:之前?
- python - 如何在条件变为真后立即获取下一个值?