用svg实现一个环形进度条

svg实现环形进度条需要用到的知识:

1、会使用path的d属性画一个圆环

//用svg的path元素的A命令画圆

<path
    d="
        M cx cy
        m 0 -r 
        a r r 0 1 0 0 2r 
        a r r 0 1 0 0 -2r"
>
></path>

//cx cy起点   r  半径

 

2、熟悉stroke,stroke-linecap,stroke-width,stroke-dasharray、stroke-dashoffset

 

话不多说,直接上代码

<div style="width: 200px;height: 200px;">
    <svg viewBox="0 0 100 100">
        <path
            d="M 50 50 m -40 0 a 40 40 0 1 0 80 0  a 40 40 0 1 0 -80 0"
            fill="none"
            stroke="#e5e9f2"
            stroke-width="5">
        ></path>
        <path
            d="M 50 50 m -40 0 a 40 40 0 1 0 80 0  a 40 40 0 1 0 -80 0"
            fill="none"
            stroke="#20a0ff"
            stroke-linecap="round"
            class="my-svg-path"
            transform="rotate(90,50,50)"
            stroke-width="5">
        </path>
    </svg>
</div>
.my-svg-path{
    stroke-dasharray: 252.2px, 252.2px;
    stroke-dashoffset: 22px;
    transition: stroke-dashoffset 0.6s ease 0s, stroke 0.6s ease 0s;
    transform: rotateZ(90deg);
    transform-origin: 50% 50%;
}

效果:

转载于:https://www.cnblogs.com/guojikun/p/10663487.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值