码迷,mamicode.com
首页 > 其他好文 > 详细

svg 圆形进度条

时间:2020-11-26 15:14:56      阅读:6      评论:0      收藏:0      [点我收藏+]

标签:ack   rip   fill   utf-8   form   ntb   html   ima   oct   

<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="utf-8">
    <title>svg 圆形进度条</title>
    <meta http-equiv="X-UA-Compatible" content="IE=Edge">
    <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0">
</head>

<body>
    <svg class="alert-circle" width="120" height="150">
        <defs>
            <lineargradient id="linear" x1="100%" y1="0%" x2="0%" y2="0%">
                <stop offset="0%" stop-color="#fdde73"></stop>
                <stop offset="100%" stop-color="#ff862c"></stop>
            </lineargradient>
        </defs>
        <g>
            <circle cx="60" cy="56" r="31" fill="none" stroke="rgba(0,0,0,0.1)" stroke-width="6"></circle>
        </g>

        <g transform="rotate(-90 60 56)">
            <circle cx="60" cy="56" r="32" transition="stroke-dashoffset .2s linear" stroke-dasharray="201,201"
                fill="none" stroke="url(#linear)" stroke-width="7" id="js-sec-circle"></circle>
        </g>
    </svg>
</body>
<script>
    setProgress(-76);
    function setProgress(num, r = 32) {
        var maxValue = 2 * Math.PI * r;
        document.getElementById(js-sec-circle).setAttribute(stroke-dashoffset, (maxValue * num / 100) - maxValue);
    }
</script>

</html>

效果

技术图片

 

svg 圆形进度条

标签:ack   rip   fill   utf-8   form   ntb   html   ima   oct   

原文地址:https://www.cnblogs.com/zhenga/p/14025060.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!