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

js實(shí)現(xiàn)div層緩慢收縮與展開的方法

 更新時(shí)間:2015年05月11日 17:59:05   投稿:shichen2014  
這篇文章主要介紹了js實(shí)現(xiàn)div層緩慢收縮與展開的方法,通過javascript自定義函數(shù)實(shí)現(xiàn)div層的收縮與展開效果,非常具有實(shí)用價(jià)值,需要的朋友可以參考下

本文實(shí)例講述了js實(shí)現(xiàn)div層緩慢收縮與展開的方法。分享給大家供大家參考。具體分析如下:

這是一個(gè)層伸縮與展開的特效代碼,帶有點(diǎn)動(dòng)畫效果,緩慢展開,DIV+JS聯(lián)合打造,看上去還不錯(cuò)。不受內(nèi)容約束,收縮與展開的速度是可以控制的,高度、循環(huán)時(shí)間也可以改。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>層收縮</title>
<script type="text/javascript">
var mh = 30;//高度
var step = 1;//每次變化的量
var ms = 10;//循環(huán)時(shí)間
function toggle(o){
 if (!o.tid)o.tid = "_" + Math.random() * 100;
 if (!window.toggler)window.toggler = {};
 if (!window.toggler[o.tid]){
  window.toggler[o.tid]={
   obj:o,
   maxHeight:o.offsetHeight,
   minHeight:mh,
   timer:null,
   action:1
  };
 }
 o.style.height = o.offsetHeight + "px";
 if (window.toggler[o.tid].timer)clearTimeout(window.toggler[o.tid].timer);
 window.toggler[o.tid].action *= -1;
 window.toggler[o.tid].timer = setTimeout("anim('"+o.tid+"')",ms );
}
function anim(id){
 var t = window.toggler[id];
 var o = window.toggler[id].obj;
 if (t.action < 0){
  if (o.offsetHeight <= t.minHeight){
   clearTimeout(t.timer);
   return;
  }
 }
 else{
  if (o.offsetHeight >= t.maxHeight){
   clearTimeout(t.timer);
   return;
  }
 }
 o.style.height = (parseInt(o.style.height, 10) + t.action * step) + "px";
 window.toggler[id].timer = setTimeout("anim('"+id+"')",ms );
}
</script>
<style type="text/css">
div.xx{
 border:solid 1px;overflow:hidden;
}
div.xx h5{
 border:solid 1px;border-width:0 0 1px;
 padding:0;margin:0;height:28px;
 line-height:30px;cursor:pointer;
 background:#eee;
}
</style>
</head>
<body>
<div class="xx"><h5 onclick="toggle(this.parentNode)">點(diǎn)擊此處層伸縮</h5>
<p>Tomat6.0的配置視頻教程,AVI電影格式,相當(dāng)清淅了,比起圖文版的教程更貼切,
不會(huì)配置Tomcat的網(wǎng)友,你可不要錯(cuò)過哦,由于視頻抓圖挺麻煩的,
試了多次還是抓了一個(gè)不太清淅的,大家將就吧。</p>
</div>
</body>
</html>

希望本文所述對(duì)大家的javascript程序設(shè)計(jì)有所幫助。

相關(guān)文章

最新評(píng)論