본문 바로가기
Web

간단한 프로그레스 바(progress bar) 만들기(HTML, CSS, JAVASCRIPT

by 싸공 2020. 7. 21.
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style scoped>
    body{
        backgroundblack;
        text-align: ce;
    }
    .conatiner{
        margin200px 50px;
        backgroundrgb(255254254);
    }
    .prog{
        width500px;
        backgroundrgb(189177177);
    }
    .progs{
        width10%;
        height50px;
        backgroundrgb(225149240);
        color:#fff;
        text-aligncenter;
        line-height50px;
    }

</style>
<body>
    <div class="conatiner">
    <h2>프로그레스 바</h2>
    <div class="prog">
        <div class="progs" id="progressing">5%</div>
    </div>
    <button onClick="moveBtn()">클릭해주세요</button>
    <br>
    </div>
    <script>
        function moveBtn(){
            var ele=document.getElementById('progressing');
            var width = 5;
            var id =setInterval(frame45);
            function frame(){
                if(width>=100){
                    clearInterval(id);
                }else{
                    width ++;
                    ele.style.width=width+"%";
                    ele.innerHTML=width+"%";
                }
            }
        }
    </script>
</body>
</html>