人人做人人澡人人爽欧美,国产主播一区二区,久久久精品五月天,羞羞视频在线观看免费

當前位置:蘿卜系統(tǒng)下載站 > 技術(shù)開發(fā)教程 > 詳細頁面

用CSS+JS制作進度條(二)

用CSS+JS制作進度條(二)

更新時間:2023-06-16 文章作者:未知 信息來源:網(wǎng)絡(luò) 閱讀次數(shù):

編程(Programming)是編定程序的中文簡稱,就是讓計算機代碼解決某個問題,對某個計算體系規(guī)定一定的運算方式,使計算體系按照該計算方式運行,并最終得到相應(yīng)結(jié)果的過程。為了使計算機能夠理解(understand)人的意圖,人類就必須將需解決的問題的思路、方法和手段通過計算機能夠理解的形式告訴計算機,使得計算機能夠根據(jù)人的指令一步一步去工作,完成某種特定的任務(wù)。這種人和計算體系之間交流的過程就是編程。

【實例名稱】

用CSS+JS制作進度條(二)

【實例描述】

本例學(xué)習(xí)如何使用CSS+JavaScript的方式實現(xiàn)常見的進度條。

【實例代碼】

<html xmlns="http://www.w3.org/1999/xhtml" > <head> <title>標題頁-本站(www.xue51.com)</title> </head> <body> <style type="text/css"> #divLoadCont{position:absolute; z-index:500; left:0; top:0; width:100%; height:98%; clip:rect(0,100%,100%,0); background-color:white; layer-background-color:white; } #divLoad1{position:absolute; layer-background-color:silver; background-color:silver} #divLoad2{position:absolute; left:0; top:0; layer-background-color:navy; background-color:navy} #divLoadText{position:absolute; background-color:transparent; font-family:arial,helvetica; color:Navy; font-size:14px; } </style> <script language="JavaScript" type="text/javascript"> function pro_bwcheck(){                     //檢測瀏覽器的代碼-通用     this.ver=navigator.appVersion     this.agent=navigator.userAgent     this.dom=document.getElementById?1:0     this.opera5=this.agent.indexOf("Opera 5")>-1     this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom && !this.opera5)?1:0;     this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom && !this.opera5)?1:0;     this.ie4=(document.all && !this.dom && !this.opera5)?1:0;     this.ie=this.ie4||this.ie5||this.ie6     this.mac=this.agent.indexOf("Mac")>-1     this.ns6=(this.dom && parseInt(this.ver) >= 5) ?1:0;     this.ns4=(document.layers && !this.dom)?1:0;     this.bw=(this.ie7 || this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns6 || this.opera5)     return this } var bw=new pro_bwcheck() numImages=12                       //默認10個圖片 loaderWidth=350                    //設(shè)置進度條的寬度 currentImg=0 function pro_doc_size(){           //判斷顯示區(qū)域   this.x=0;this.x2=bw.ie && document.body.offsetWidth-20||innerWidth||0;   this.y=0;this.y2=bw.ie && document.body.offsetHeight-5||innerHeight||0;   if(!this.x2||!this.y2) return message('窗體的寬度和高度不夠!')   this.x50=this.x2/2;this.y50=this.y2/2;   return this; } function pro_obj(obj,nest){            //定義頁面中承載進度條的控件屬性   nest=(!nest) ? "":'document.'+nest+'.'   this.evnt=bw.dom? document.getElementById(obj): bw.ie4?document.all[obj]:bw.ns4?eval (nest+"document.layers." +obj):0;      this.css=bw.dom||bw.ie4?this.evnt.style:this.evnt;   this.ref=this.css   this.w=this.evnt.offsetWidth||this.css.clip.width||     this.ref.width||this.css.pixelWidth||0;   return this } pro_obj.prototype.moveIt = function(x,y){              //定義移動方法   this.x=x;this.y=y; this.css.left=x;this.css.top=y } pro_obj.prototype.clipTo = function(t,r,b,l,setwidth){ //重新定義裁剪方法   this.ct=t; this.cr=r; this.cb=b; this.cl=l   if(bw.ns4){     this.css.clip.top=t;this.css.clip.right=r     this.css.clip.bottom=b;this.css.clip.left=l   }else{     if(t<0)t=0;if(r<0)r=0;if(b<0)b=0;if(b<0)b=0     this.css.clip="rect("+t+","+r+","+b+","+l+")";     if(setwidth){this.css.pixelWidth=this.css.width=r;     this.css.pixelHeight=this.css.height=b}   } } var oLoad2 function startLoading(){   page=new pro_doc_size()   //以下設(shè)置加載控件的一些基本屬性   oLoadCont=new pro_obj('divLoadCont')   oLoad=new pro_obj('divLoad1','divLoadCont')   oLoad2=new pro_obj('divLoad2',' divLoadCont.document.divLoad1')   oLoadText=new pro_obj('divLoadText', 'divLoadCont.document.divLoad1')   oLoad.moveIt(page.x50-loaderWidth/2,page.y50-20)   oLoadText.moveIt(loaderWidth/2 - oLoadText.w/2,10)   oLoad.clipTo(0,loaderWidth,40,0,1)   //裁剪區(qū)域   oLoad2.per = loaderWidth/numImages   //百分比 } function loadIt_display(ok){   currentImg++   if(oLoad2) oLoad2.clipTo(0,oLoad2.per*currentImg,40,0,1)       //裁剪顯示的區(qū)域   if(currentImg<=numImages) setTimeout("loadIt_display(1)",200)  //使用定時器不斷加載圖片   else{     oLoadCont.css.visibility='hidden'                            //進度條加載完成后隱藏   } } </script> <div id="divLoadCont">   <div id="divLoad1">     <div id="divLoad2"></div><br>     <div id="divLoadText">頁面加載中,請稍候...</div>   </div> </div> <script>     startLoading()     loadIt_display(1) </script> </body> </html>

【運行效果】

 用CSS+JS制作進度條(二)運行效果

【難點剖析】

本例的重點在于樣式表中div層的布局。樣式表設(shè)置div的背景色和邊框顏色為藍色,然后使用JavaScript計算進度條的寬度和每次顯示的進度,其中重點是“clipTo”方法。本例重新定義了此方法,目的是實現(xiàn)一個矩形塊狀區(qū)域的顯示。

【源碼下載】

為了JS代碼的準確性,請點擊:用CSS+JS制作進度條(二) 進行本實例源碼下載 


使用編程語言寫的程序,由于每條指令都對應(yīng)計算機一個特定的基本動作,所以程序占用內(nèi)存少、執(zhí)行效率高。

溫馨提示:喜歡本站的話,請收藏一下本站!

本類教程下載

系統(tǒng)下載排行

網(wǎng)站地圖xml | 網(wǎng)站地圖html
主站蜘蛛池模板: 武宣县| 赣州市| 杭锦旗| 翁牛特旗| 陇南市| 南平市| 汪清县| 扶余县| 辽宁省| 墨江| 双鸭山市| 苏尼特右旗| 会同县| 漳浦县| 泸西县| 上林县| 抚州市| 米泉市| 新安县| 闻喜县| 台前县| 花莲县| 漯河市| 成武县| 宝山区| 福清市| 罗平县| 屯留县| 平原县| 饶平县| 紫阳县| 介休市| 铜川市| 玛纳斯县| 翼城县| 当雄县| 弋阳县| 集安市| 辽宁省| 廊坊市| 南华县|