svg动画效果实例分享

1967
1

前端小姐姐 小试身手Lv3

发表于2021-11-26 16:36

楼主
本帖最后由 前端小姐姐 于 2021-11-26 16:41 编辑

1、效果展示分别是3个小动画效果,效果如下:



2、代码展示:
(1)第一个动画只有html代码:
html:
<svg width="650" height="650" viewBox="0 0 650 650" version="1.1" xmlns="http://www.w3.org/2000/svg">

    <circle cx="100" cy="550" r="50" fill="#00BFFF" opacity="0">
        <animate attributeName="opacity" values="0;1;0;1;0;1;0;1" begin="0s" dur="0.5s" repeatCount="1" fill="freeze"/>
    </circle>

    <path stroke="#00BFFF" stroke-width="5" d="M100,550 L100,550">
        <animate attributeName="d" values="M100,550 L100,550;M100,550 L500,350" begin="0.5s" dur="0.5s" repeatCount="1" fill="freeze"/>
    </path>

    <circle cx="500" cy="350" r="50" fill="#00BFFF" opacity="0">
        <animate attributeName="opacity" values="0;1;0;1;0;1;0;1" begin="1s" dur="0.5s" repeatCount="1" fill="freeze"/>
    </circle>
</svg>
(2)第二个动画有html+css代码:①html:
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" class="circle-load-rect-svg" width="300" height="200" viewbox="0 0 600 400">
    <polyline points="5 5, 575 5, 575 200, 5 200" class="g-rect-path"/>
    <polyline points="5 5, 575 5, 575 200, 5 200" class="g-rect-fill"/>
</svg>
②css:.
g-rect-path{
    fill: none;
    stroke-width:10;
    stroke:#d3dce6;
    stroke-linejoin:round;
    stroke-linecap:round;
}
.g-rect-fill{
    fill: none;
    stroke-width:10;
    stroke:#ff7700;
    stroke-linejoin:round;
    stroke-linecap:round;
    stroke-dasharray: 0, 1370;
    stroke-dashoffset: 0;
    animation: lineMove 2s ease-out infinite;
}
@keyframes lineMove {
    0%{
        stroke-dasharray: 0, 1350;
    }
    100%{
        stroke-dasharray: 1350, 1350;
    }
}
(3)第三个动画有html+css代码:①html:<svg width="14" height="14" viewBox="0 0 14 14" version="1.1" xmlns="http://www.w3.org/2000/svg">
    <circle cx="7" cy="7" r="5" stroke-width="3" stroke="#00A5E0" fill="none" class="lineMove1"></circle>
</svg>
②css:.lineMove1{
    stroke-dasharray: 0, 32;
    stroke-dashoffset: 0;
    animation: lineMove1 2s ease-out infinite;
}
@keyframes lineMove1 {
    0%{
        stroke-dasharray: 0, 32;
    }
    100%{
        stroke-dasharray: 32, 32;
    }
}






最近看过此主题的会员

一一

1个回答

只看楼主

hesj 初学数据Lv2

发表于2022-3-28 11:43

只看该作者

取消 关注该作者的回复

沙发

本帖最后由 hesj 于 2022-3-28 11:46 编辑

请问这是用在哪里的呢,制作报表的时候可以使用吗

登录后可回答问题,请登录注册

快速回复 返回顶部 返回列表

小时

全天响应

分钟

快速处理问题

工程师强势助力

明星产品
解决方案
联系合作

400咨询:400-0011-866

技术支持QQ:400-0011-866(工作日9:00-18:00)

产品建议邮箱yixin@esensoft.com

关注我们

扫TA学习更多干货

一对一专家交流

版权所有© 2006-2024 北京亿信华辰软件有限责任公司 京ICP备07017321号 京公网安备11010802016281号