天天看点

html原型进度条

直接上代码,简单的很

<!doctype html>
<html >
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        .circle-progress{
            position: relative;
            width: 100px;
            height: 100px;
            animation: progressMove linear 5s infinite;
        }
        .circle-progress .item{
            position: absolute;
            left: 0;
            right: 0;
            width: 100%;
            height: 100%;
        }
        .circle-progress .bar{
            position: absolute;
            width: 5%;
            height: 15%;
            left: 50%;
            transform: translateX(-50%);
            background-color: #aaa;
        }
        @keyframes progressMove {
            from{
                transform: rotate(0deg);
            }
            to{
                transform: rotate(360deg);
            }
        }
    </style>
</head>
<body>
<div class="circle-progress circleProgress">
    <div class="item">

    </div>
</div>

<script>
    var box = document.querySelector('.circleProgress');
    for(var i=0;i<18;i++){
        var html = document.createElement('div');
        html.classList = 'item';
        html.classList.add('item'+i);
        html.innerHTML = '<div class="bar"></div>';
        html.style.transform = 'rotate('+i*15+'deg)';
        html.style.opacity = i/20;
        box.appendChild(html)
    }
</script>
</body>
</html>