H5移動(dòng)端 進(jìn)度條加載

<!DOCTYPE html>  
<html>  
<head>  
    <meta charset="UTF-8">  
    <title>移動(dòng)端進(jìn)度條</title>  
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />  
    <style>  
        html {  
          font-size: 20px;  
        }  
        body {  
          font-size: 16px;  
          font-family: "微軟雅黑";  
        }  
        @media only screen and (max-width: 320px) {    html {   
                font-size: 42.7px !important;   
            }}   
        @media only screen and (min-width: 321px) and (max-width: 360px) {    html {   
                font-size: 48px !important;   
            }}   
        @media only screen and (min-width: 361px) and (max-width: 375px) {    html {   
                font-size: 50px !important;   
            }}   
        @media only screen and (min-width: 376px) and (max-width: 384px) {    html {   
                font-size: 52.1px !important;   
            }}   
        @media only screen and (min-width: 385px) and (max-width: 414px) {    html {   
                font-size: 55.2px !important;   
            }}   
        @media only screen and (min-width: 415px) and (max-width: 480px) {    html {   
                font-size: 64px !important;   
            }}   
        @media only screen and (min-width: 481px) and (max-width: 540px) {    html {   
                font-size: 72px !important;   
            }}  
        @media only screen and (min-width: 750px) {    html {   
                font-size: 100px !important;   
            }}  
  
        .loading_fater{  
            width: 4.14rem;  
            height: 0.44rem;  
            line-height: 0.44rem;
            background: #391956;  
            border: 3px solid #FFFFFF;  
            box-shadow: 0 3px 7px 0 rgba(189,16,224,0.50);  
            border-radius: 100px;  
            position: relative;
            margin: 50% auto 0;
        }  
        .loading{   
            width: 0.02rem;  
            height: 0.44rem;  
            background: #FE6365;  
            box-shadow: inset 0 0 4px 0 #470707;  
            border-radius: 100px;  
        }  
        .loading_fater> span{  
            color: white;  
            position: absolute;  
            top: 0;  
            left: 2rem;  
        }  
    </style>  
</head>  
<body>  
    <div class="loading_fater">  
        <div class="loading"></div>  
        <span><label class="bfb">0</label>%</span>  
    </div>  
      
    <script type="text/javascript">   
          
        /** 
         * 由于js并不能獲取下載所需資源包文件大小  
         * 所以只能在頁面各個(gè)部位插入代碼片段, 更新進(jìn)度條, 以模擬資源下載(讀取)進(jìn)度 
         */  
          
        updateLoading(10,1);
          
        //用延遲  模擬加載文件需要的時(shí)間 
        setTimeout(function(){  
            updateLoading(60,1);  
        },1000) 

        setTimeout(function(){  
            updateLoading(100,1);  
        },3000)  
          
        var bfb = document.getElementsByClassName('bfb')[0];  
        /** 
         * 更新進(jìn)度條 
         * @param {Object} bfb_num :更新進(jìn)度條數(shù)字baifenbi (10) 
         * @param {Object} millisecond :動(dòng)畫執(zhí)行毫秒數(shù) 
         */  
        function updateLoading(bfb_num,millisecond){  
              
            document.getElementsByClassName('loading')[0].style.cssText = 'width: '+bfb_num+'%;transition-duration:'+millisecond+'s;'  
              
            var load_Interval = setInterval(function(){  
                if(bfb.innerHTML < bfb_num){  
                    bfb.innerHTML = parseInt(bfb.innerHTML)+1;  
                }else{  
                    clearInterval(load_Interval);  
                }  
            },millisecond*1000/bfb_num)  
        }  
          
    </script>   
</body>  
</html>  
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容