标签:
此进度条仅作为伪劣显示作用,不提供实际作业,提供开始走和结束两个方法。。。
html中图片如上图
<body> <div id="upPreg"> <div id="upPregA"> <img id="upPregImg" src="images/Up_Preg.png"> </div> <div id="upPregBg"></div> </div> <div class="bgDiv" id="bgDiv"></div> </body>
#upPreg{ width:360px; height:48px; position:absolute; top:0;left:0;right:0;bottom:0; margin:auto; z-index:1001; } #upPregA{ width:100%; height:32px; position:absolute; top:5px; left:0px; overflow:hidden; border-radius:50px 0px 0px 50px; } #upPregBg{ width:300px; height:18px; position:absolute; top:12px;left:0; border-radius:10px; background-color:#c2c2c2; z-index:999; } #upPregImg{ width:300px; height:32px; position:absolute; top:0px; left:-270px; z-index:1001; } #bgDiv { position: fixed; top: 0px; background: black; opacity: 0.5; left: 0px; width: 100%; height: 100%; z-index: 100; display:none; }
$(function(){ var ccc=new ceartPregress();//创建进度条 ccc.start(); setTimeout(function(){ ccc.end(); },4000) //ccc.end(); //进度完成 }) //构造进度条 function ceartPregress() { this.oEle=document.getElementById("upPregImg"); this.oDiv=document.getElementById("upPreg"); this.oBg=document.getElementById("bgDiv"); this.timer1=null; this.timer2=null; } //开始 ceartPregress.prototype.start=function() { this.oDiv.style.display="block"; this.oBg.style.display="block"; var ele=this.oEle; var eft=-270; this.timer1=setInterval(function(){ if(eft<-30){ eft++; ele.style.left=eft+"px"; } else{ clearInterval(this); } },300) } //完成 ceartPregress.prototype.end=function() { this.oDiv.style.display="block"; this.oBg.style.display="block"; var _oDiv=this.oDiv; var _oBg=this.oBg; var ele=this.oEle; var _ccc=getStyle(ele, "left") var eft=parseInt(_ccc); clearInterval(this.timer1); this.timer2=setInterval(function(){ if(eft<0){ eft+=1; ele.style.left=eft+"px"; } else{ clearInterval(this); _oDiv.style.display="none"; _oBg.style.display="none"; } },10) } //获取对象属性 function getStyle(obj, name) { if(obj.currentStyle) { return obj.currentStyle[name]; } else { return getComputedStyle(obj, false)[name]; } }
标签:
原文地址:http://www.cnblogs.com/pangys/p/5719825.html