svg-写一个简单的进度条

本文介绍了一种使用SVG和CSS实现的线条加载动画效果。通过定义SVG路径和利用CSS动画控制线条填充的方式,实现了从无到有的线条绘制过程。这种动画效果常用于页面加载或进度指示等场景。

html

<div class="container">
    <div class="line-wrap">
        <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" fill="none" class="g-rect-path"/>
            <polyline points="5 5, 575 5, 575 200, 5 200" fill="none" class="g-rect-fill"/>
        </svg>
    </div>
</div>

css

 body{
            font-size:10px;
        }

        .container{
            width: 100%;
        }
        .line-wrap{
            width:300px;
            margin:0 auto;
        }
        .circle-load-rect-svg{
            margin: 10px;
        }

        .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;
            }
        }

 

转载于:https://www.cnblogs.com/yangshangjin/p/7016067.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值