日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

看来我的计时器的应用还要加强才行呀

發(fā)布時間:2025/4/14 编程问答 24 豆豆
生活随笔 收集整理的這篇文章主要介紹了 看来我的计时器的应用还要加强才行呀 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

本來想照著網(wǎng)上的效果模擬一個(說來慚愧,我現(xiàn)在除了模仿就是抄),忽然發(fā)現(xiàn)我對計時器的應(yīng)用不是很熟練,本想來面向?qū)ο蟮?#xff0c;可是我覺得還是先聯(lián)系計時器,增加一下基礎(chǔ)知識吧,要不感覺好不給力啊。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>幻燈片</title> <style type="text/css"> * {margin:0;padding:0;} body {font-size:12px;color:#222;font-family:Verdana, Arial, Helvetica, sans-serif;background:#f0f0f0;} ul, li {list-style:none;} img {border:0;display:block;width:100%;} #focus {width:1200px;height:300px;overflow:hidden;margin:0 auto;margin:100px auto;position:relative;} #focus ul{ height:280px;} #focus ul li {display:block;position:absolute;} .a {width:600px;height:210px;left:0;top:20px;z-index:1;} .b {width:700px;height:245px;left:100px;top:10px;z-index:2} .c {width:800px;left:200px;top:0;z-index:3} .d {width:700px;height:245px;left:400px;top:10px;z-index:2} .e {width:600px;height:210px;left:600px;top:20px;z-index:1;} .indexNum{ height:20px; text-align:center;} .indexNum a{ display:inline-block; width:15px; background:#990; height:15px; margin:5px 2px 0 2px;;} .indexNum a.cur{ background:#6F3;} </style> <script type="text/javascript"></script> </head> <body> <div id="focus"><ul><li class="c"><img src="img/03.jpg" /></li><li class="d"><img src="img/04.jpg" /></li><li class="e"><img src="img/05.jpg" /></li><li class="a"><img src="img/01.jpg" /></li><li class="b"><img src="img/02.jpg" /></li></ul> </div></body> </html> <script type="text/javascript"> var o=document.getElementById("focus"); var aLi=o.getElementsByTagName("li"); var timer=null;var aBtnWrap=document.createElement("div"); aBtnWrap.className="indexNum";for(var i=0;i<aLi.length;i++){var aBtn=document.createElement("a");aBtnWrap.appendChild(aBtn); } o.appendChild(aBtnWrap);var aBtn=o.getElementsByTagName("div")[0].getElementsByTagName("a"); var arr=[]; var key=0; aBtn[key].className="cur";for(var i=0;i<aLi.length;i++){aLi[i].style.cssText="top:"+creatJson(aLi[i]).top+"px;left:"+creatJson(aLi[i]).left+"px;width:"+creatJson(aLi[i]).width+"px;height:"+creatJson(aLi[i]).height+"px;z-index:"+creatJson(aLi[i]).zIndex;aLi[i].removeAttribute("class","");arr.push(creatJson(aLi[i])); }for(var i=0;i<aLi.length;i++){aBtn[i].index=aLi[i].index=i;aBtn[i].onclick=aLi[i].onclick=function(){key=this.index;switchs(key)} }function switchs(key){var t=[];for(c=0;c<aBtn.length;c++){aBtn[c].className=""; }aBtn[key].className="cur";//制造新數(shù)組并且運動交換位置for(z=0;z<aLi.length;z++){if(key==aLi.length){key=0;}t[key]=arr[z];key++;}for(q=0;q<aLi.length;q++){ move(aLi[q],t[q]) }} function auto(){ clearInterval(timer); timer=setInterval(function(){key++;if(key==aLi.length){key=0;}switchs(key); },1000) } o.onmouseover=function(){clearInterval(timer); } o.onmouseout=function(){auto() } auto()//制作json數(shù)據(jù) function creatJson(obj){var Json={};Json.top=parseInt(getcss(obj,"top"));Json.left=parseInt(getcss(obj,"left"));Json.width=parseInt(getcss(obj,"width"));Json.height=parseInt(getcss(obj,"height"));Json.zIndex=parseInt(getcss(obj,"zIndex"));return Json; }//運動框架,不包含透明度 function move(obj,json,fn){clearInterval(obj.timer) obj.timer=setInterval(function(){obj.bstop=true;for(i in json){if(i=="zIndex"){obj.style.zIndex=json[i];}else{var pos=parseInt(getcss(obj,i));var speed=pos>json[i]?Math.floor(((json[i]-pos)/5)): Math.ceil(((json[i]-pos)/5));obj.style[i]=speed+pos+"px";if(parseInt(getcss(obj,i))!=json[i]){obj.bstop=false;}}}if(obj.bstop){clearInterval(obj.timer);fn && fn();} },30) }//獲取計算后的樣式 function getcss(obj,attr){return (obj.currentStyle||getComputedStyle(obj, false))[attr]; } </script>

?

轉(zhuǎn)載于:https://www.cnblogs.com/busicu/p/3992755.html

總結(jié)

以上是生活随笔為你收集整理的看来我的计时器的应用还要加强才行呀的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。