• js进度条


    <!DOCTYPE html>
    <html>
        <head>
            <meta charset="UTF-8">
            <title></title>
            <style>
                #progressBox{
                     300px;
                    height: 40px;
                    border: 1px solid #cbcbcb;
                    background: white;
                    position: relative;
                }
                #progressBar{
                    position: absolute;
                    left: 0;
                    top: 0;
                    z-index: 2;
                    height: 40px;
                     100%;
                    line-height: 40px;
                    color: white;
                    text-align: center;
                    font-size: 20px;
                    font-weight: bold;
                    font-family: georgia;
                    clip: rect(0px,10px,40px,0px);
                    background: #00a1f5;
                }
                #progressText{
                    position: absolute;
                    left: 0;
                    top: 0;
                    z-index: 1;
                    height: 40px;
                    line-height: 40px;
                     100%;
                    color: black;
                    text-align: center;
                    font-size: 20px;
                    font-weight: bold;
                }
            </style>
            <script>
                window.onload=function(){
                    var iNow=0;
                    var timer=setInterval(function(){
                        if(iNow==100){
                            clearInterval(timer);
                        }else{
                            iNow+=1;
                            progressFn(iNow);
                        }
                        
                    },30)
                    function progressFn(cent){
                        var oDiv1=document.getElementById("progressBox");
                        var oDiv2=document.getElementById("progressBar");
                        var oDiv3=document.getElementById("progressText");
                        
                        var allWidth=parseInt(getStyle(oDiv1,'width'));
                        oDiv2.innerHTML=cent+"%";
                        oDiv3.innerHTML=cent+"%";
                        oDiv2.style.clip='rect(0px,'+ cent/100 * + allWidth +'px,40px,0px)';
                        function getStyle(obj,attr){
                            if(obj.currentStyle){
                                return obj.currentStyle[attr];
                            }else{
                                return getComputedStyle(obj,false)[attr];
                            }
                        }
                    }
                }
            </script>
        </head>
        <body>
            <div id="progressBox">
                <div id="progressBar">0%</div>
                <div id="progressText">0%</div>
            </div>
        </body>
    </html>
  • 相关阅读:
    如何理解css3 -webkit-animation-fill-mode属性值为both时的使用方法
    关于对canvas.beginPath()的理解
    [cf10E]Greedy Change
    [atAGC055B]ABC Supremacy
    [loj6734]图上的游戏
    [gym102412D]The Jump from Height of Self-importance to Height of IQ Level
    [Aizu1410]Draw in Straight Lines
    [Aizu2993]Invariant Tree
    [zoj3990]Tree Equation
    [hdu6326]Monster Hunter
  • 原文地址:https://www.cnblogs.com/gxywb/p/10255877.html
Copyright © 2020-2023  润新知