欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

簡(jiǎn)單的網(wǎng)頁(yè)廣告特效實(shí)例

 更新時(shí)間:2017年08月19日 09:40:17   投稿:jingxian  
下面小編就為大家?guī)?lái)一篇簡(jiǎn)單的網(wǎng)頁(yè)廣告特效實(shí)例。小編覺(jué)得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧

為了練習(xí)javascript,做了一個(gè)簡(jiǎn)單的demo,實(shí)現(xiàn)的是廣告從頂部慢慢拉出到最大,然后停留2s,再收縮到比較小且可以關(guān)閉的廣告特效。圖片可以替換為任意其他的圖片。

代碼如下

<!DOCTYPE html>
<html>
<head lang="en">
 <meta charset="UTF-8">
 <title></title>
 <style>
  #ad{
   width:962px;
   display:none;
   margin:0 auto;
   overflow:hidden;
   position:relative;
  }
  #main{
   margin:0 auto;
   width:960px;
   height:1700px;
  }
  #close{
   width:20px;
   height:20px;
   position:absolute;
   top:0;
   right:0;
   font-size:16px;
   line-height:20px;
   text-align:center;
   display:none;
   background:yellowgreen;
  }
 </style>

</head>
<body>
<div id="ad">
 <img src="ad.png" id="imgAd" width="962" height="386">
 <img src="cur.png" id="curAd" width="1199" height="68">
 <span id="close">x</span>
</div>
<div id="main"><img src="數(shù)字商品-10-23.jpg"></div>
<script>
 var oImgAd=document.getElementById('imgAd');
 var oad=document.getElementById('ad');
 var ocur=document.getElementById('curAd');
 var closeBtn=document.getElementById('close');
 var h=0;
 var maxH=oImgAd.height;
 var minH=ocur.height;
 function down()
 {
  if(h<maxH)
  {
   h+=5;
   oad.style.height=h+"px";
   oad.style.display="block";
   setTimeout(down,5);
  }
  else{
   setTimeout(up,2000);
  }
 }
 function up(){
  if(h>minH){
   h-=5;
   oad.style.height=h+"px";
   setTimeout(up,5);
  }
  else{
   oImgAd.style.display='none';
   closeBtn.style.display='block';
  }
 }
 closeBtn.onclick=function(){
  oad.style.display='none';
 }
 setTimeout(down,1000);
</script>
</body>
</html>

以上這篇簡(jiǎn)單的網(wǎng)頁(yè)廣告特效實(shí)例就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論