最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

原生js實(shí)現(xiàn)網(wǎng)頁(yè)頂部自動(dòng)下拉/收縮廣告效果

 更新時(shí)間:2017年01月20日 14:58:47   作者:夏天不做夢(mèng)  
本文主要介紹了原生js實(shí)現(xiàn)網(wǎng)頁(yè)頂部自動(dòng)下拉/收縮廣告效果的實(shí)例代碼。具有一定的參考價(jià)值,下面跟著小編一起來(lái)看下吧

知識(shí)要點(diǎn)

1.實(shí)現(xiàn)原理:

通過(guò)遞歸改變div的高度值達(dá)到緩慢下拉的效果。

2.一共分為3個(gè)步驟我寫(xiě)了三個(gè)函數(shù)

第一個(gè)show()函數(shù)(下拉):初始值高度h<300的話(huà) h+5  反之return退出停止,調(diào)用setTimeout方法30毫秒執(zhí)行一次+5

第二個(gè)hide()函數(shù)(收回):只是高度的判斷不同高度h-5 反之return退出停止,調(diào)用setTimeout方法30毫秒執(zhí)行一次-5

第三個(gè)dd()函數(shù)(再次彈出):這里要注意的是第二次彈出的div是一個(gè)新的div把它的高度設(shè)置為0,實(shí)現(xiàn)原理與第一個(gè)函數(shù)一樣,

并且一定要在第二個(gè)函數(shù)(收回)執(zhí)行后再執(zhí)行

完整代碼

<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>demo</title>
<style>
body,h1,h2,h3,h4,h5,h6,hr,p,blockquote,dl,dt,dd,ul,ol,li,pre,form,fieldset,legend,button,input,textarea,th,td{margin:0;padding:0;}
h1,h2,h3,h4,h5,h6{font-size:100%;}
address,cite,dfn,em,var{font-style:normal;}
code,kbd,pre,samp{font-family:courier new,courier,monospace;}
ul,ol{list-style:none;}
a{text-decoration:none;}
a:hover{text-decoration:none;}
sup{vertical-align:text-top;}
sub{vertical-align:text-bottom;}
legend{color:#000;}
fieldset,img{border:0;}
button,input,select,textarea{font-size:100%;}
table{border-collapse:collapse;border-spacing:0;}
.clear{clear: both;float: none;height: 0;overflow: hidden;}
#container{width: 600px; margin: 0 auto;}
p{ line-height: 28px; }
.hidden{background: #E6E6E6; text-align: center; height: auto; overflow: hidden;}
.show{ background: #808080;text-align: center; height: 0; overflow: hidden; }
</style> 
</head> 
<body>
 <div id="container">
  <div class="hidden" id="hid"><p>廣告圖</p></div>
  <div class="show" id="sho"><p>哈哈哈哈改裝成功</p></div>
 </div>
 <script type="text/javascript"> 
 window.onload=function aa(){
 show();
 setTimeout("hide()",3000);
 }
 var h=0;
 var hid=document.getElementById("hid");
 var sho=document.getElementById("sho");
 function show(){
 if(h<300){
  h+=5;
  hid.style.height=h+"px";
 }else{
  return;
 }
 setTimeout("show()",30);
 } 
 function hide(){
 if(h>0){
  h-=5;
  hid.style.height=h+"px";
 }else{
  dd();
  return;
 }
 setTimeout("hide()", 30);
 }
 var a=0;
 function dd(){
 if(a<60){
  a+=1;
  sho.style.height=a+"px";
 }else{
  return;
 }
 setTimeout("dd()",30);
 }
 </script>
</body> 
</html> 

以上就是本文的全部?jī)?nèi)容,希望本文的內(nèi)容對(duì)大家的學(xué)習(xí)或者工作能帶來(lái)一定的幫助,同時(shí)也希望多多支持腳本之家!

相關(guān)文章

最新評(píng)論

东至县| 台北市| 满洲里市| 武城县| 丰原市| 扶余县| 如皋市| 林州市| 平潭县| 北京市| 达拉特旗| 凌源市| 开化县| 丽水市| 女性| 弥勒县| 玉树县| 萝北县| 同仁县| 彰武县| 甘洛县| 甘南县| 洱源县| 乌拉特前旗| 高州市| 承德市| 宁津县| 通化市| 威信县| 呼和浩特市| 前郭尔| 汶川县| 大同县| 东阿县| 四川省| 崇礼县| 年辖:市辖区| 西贡区| 东兴市| 东台市| 东阿县|