圆环式百分比进度条

作者: Miss_Fairy | 来源:发表于2017-08-07 17:16 被阅读0次

效果图展示

image.png

下面是实现代码

<!DOCTYPE html>
<meta charset="utf-8">
<html>
<head>
    <title></title>
    <style type="text/css">
        *{
            margin: 0;
            padding: 0;
        }
        .box {
            border: 1px solid #ccc;
            width: 200px;
            height: 200px;
            margin: 100px auto;
            position: relative;
            line-height: 200px;
            text-align: center;
            box-sizing: border-box;
        }
        /*把整个盒子分成两个部分,通过overflow:hidden进行显示隐藏*/
        .left,.right {
            position: absolute;
            top: 0;
            width: 100px;
            height: 200px;

            overflow: hidden;
        }
        .left {
            left: 0;
        }
        .right {
            right: 0;
        }
        /*进度条的底色部分*/
        .progress {
            width: 160px;
            height: 160px;
            border: 20px solid #a4ccfb;
            border-radius: 50%;
            position: absolute;
            top: 0;
        }
        .progress-left {
            border-top: 20px solid #09c;
            border-right: 20px solid #09c;
            left: 0;
            -webkit-animation: run1 10s linear infinite;
        }
        @keyframes run1 {
            0% {
                -webkit-transform: rotate(45deg);
            }
            50% {
                -webkit-transform: rotate(45deg);
            }
            100% {
                -webkit-transform: rotate(225deg);
            }
        }

        .progress-right {
            border-bottom: 20px solid #09c;
            border-left: 20px solid #09c;
            right: 0;
            -webkit-animation: run 10s linear infinite;
        }
        @keyframes run {
            0% {
                -webkit-transform: rotate(45deg);
            }
            50% {
                -webkit-transform: rotate(225deg);
            }
            100% {
                -webkit-transform: rotate(225deg);
            }
        }
        .num {
            font-size: 20px;
        }

    </style>
</head>
<body>
    <div class="box">
        <div class="left">
            <div class="progress progress-left"></div>
        </div>
         <div class="right">
            <div class="progress progress-right"></div>
        </div>
        <div class="num"><span id="num">0</span>%</div>
    </div>
    <script type="text/javascript">
        var num = document.getElementById("num");
        var i = 0;
        function addNum(){
            i++;
            if(i>100){
                i = 0;
            }
            num.innerHTML = i;
        }
        setInterval(addNum,100);
    </script>
</body>
</html>

相关文章

网友评论

    本文标题:圆环式百分比进度条

    本文链接:https://www.haomeiwen.com/subject/yrualxtx.html