Board logo

標題: [Flash] yahoo首頁伸縮效果正文 [打印本頁]

作者: kayin    時間: 2008-2-21 02:55 PM     標題: yahoo首頁伸縮效果正文

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  2. "http://big5.chinaz.com:88/www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  3. <html xmlns="http://big5.chinaz.com:88/www.w3.org/1999/xhtml">
  4. <head>
  5. <title>runcode</title>
  6. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  7. <meta name="Author" content="Sheneyan" />
  8. <script type="text/javascript">
  9. var mh = 30;//最小高度
  10. var step = 1;//每次變化的px量
  11. var ms = 10;//每隔多久循環一次
  12. function toggle(o){
  13.   if (!o.tid)o.tid = "_" + Math.random() * 100;
  14.   if (!window.toggler)window.toggler = {};
  15.   if (!window.toggler[o.tid]){
  16.     window.toggler[o.tid]={
  17.       obj:o,
  18.       maxHeight:o.offsetHeight,
  19.       minHeight:mh,
  20.       timer:null,
  21.       action:1
  22.     };
  23.   }
  24.   o.style.height = o.offsetHeight + "px";
  25.   if (window.toggler[o.tid].timer)clearTimeout(window.toggler[o.tid].timer);
  26.   window.toggler[o.tid].action *= -1;
  27.   window.toggler[o.tid].timer = setTimeout("anim('"+o.tid+"')",ms );
  28. }
  29. function anim(id){
  30.   var t = window.toggler[id];
  31.   var o = window.toggler[id].obj;
  32.   if (t.action < 0){
  33.     if (o.offsetHeight <= t.minHeight){
  34.       clearTimeout(t.timer);
  35.       return;
  36.     }
  37.   }
  38.   else{
  39.     if (o.offsetHeight >= t.maxHeight){
  40.       clearTimeout(t.timer);
  41.       return;
  42.     }
  43.   }
  44.   o.style.height = (parseInt(o.style.height, 10) + t.action * step) + "px";
  45.   window.toggler[id].timer = setTimeout("anim('"+id+"')",ms );
  46. }
  47. </script>
  48. <style type="text/css">
  49. div.xx{border:solid 1px;overflow:hidden;}
  50. div.xx h5{border:solid 1px;border-width:0 0 1px;padding:0;margin:0;height:30px;line-height:30px;cursor:pointer;background:#eee;}
  51. </style>
  52. </head>
  53. <body>
  54. <div class="xx"><h5 onclick="toggle(this.parentNode)">點擊我看"伸縮效果"</h5>
  55. <p><a href="http://big5.chinaz.com:88/www.chinaz.com/">中國站長站</a></p>
  56. <p><a href="http://big5.chinaz.com:88/sc.chinaz.com/">站長素材站</a></p>
  57. <p><a href="http://big5.chinaz.com:88/myjs.chinaz.com/">站長腳本站</a></p>
  58. <p><a href="http://big5.chinaz.com:88/down.chinaz.com/">站長下載</a></p>
  59. </div>
  60. </body>
  61. </html>
複製代碼
轉載自:
http://big5.chinaz.com:88/myjs.c ... ass=30&cid=1089




歡迎光臨 Kuroshio Ocean Design - 黑潮設計 (http://forum.kod.tw/) Powered by Discuz! 7.2