国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JavaScript > 正文

js實現div層緩慢收縮與展開的方法

2019-11-20 12:30:18
字體:
來源:轉載
供稿:網友

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

這是一個層伸縮與展開的特效代碼,帶有點動畫效果,緩慢展開,DIV+JS聯合打造,看上去還不錯。不受內容約束,收縮與展開的速度是可以控制的,高度、循環時間也可以改。

<!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;//循環時間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)">點擊此處層伸縮</h5><p>Tomat6.0的配置視頻教程,AVI電影格式,相當清淅了,比起圖文版的教程更貼切,不會配置Tomcat的網友,你可不要錯過哦,由于視頻抓圖挺麻煩的,試了多次還是抓了一個不太清淅的,大家將就吧。</p></div></body></html>

希望本文所述對大家的javascript程序設計有所幫助。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 运城市| 侯马市| 丰台区| 吉安县| 三都| 东乌| 华蓥市| 滦平县| 石门县| 疏附县| 塘沽区| 思茅市| 白朗县| 崇左市| 共和县| 永登县| 慈利县| 马边| 正阳县| 曲水县| 扬州市| 香港| 广饶县| 清苑县| 平塘县| 九台市| 嘉鱼县| 北流市| 攀枝花市| 凤翔县| 贵南县| 登封市| 右玉县| 双桥区| 许昌县| 巴彦淖尔市| 云龙县| 新津县| 惠东县| 太康县| 尼勒克县|