默认版块

您所在的位置:合元网络»|||默认版块222222论坛 代码学习 默认版块 几个不错的自动收缩菜单导航效果  
打印 上一主题 下一主题

几个不错的自动收缩菜单导航效果

查看: 1038 发表于 2016-10-14 21:58:23 [复制链接]
第一段代码  一开始是展开的
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  3. <html xmlns="http://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>内容</p>
  56. <p>内容</p>
  57. <p>内容</p>
  58. <p>内容</p>
  59. </div>
  60. <div class="xx"><h5 onclick="toggle(this.parentNode)">伸缩效果</h5>
  61. <p>sdf容</p>
  62. <p>sdf容</p>
  63. <p>sf容</p>
  64. <p>sfd容</p>
  65. </div>
  66. </body>
  67. </html>
复制代码


第二个代码 一开始是收缩的
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  3. <html xmlns="http://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. var caiying2007=202//最大高度
  13. window.onload=function init(){
  14. var obj_init=document.getElementsByTagName("div")
  15. for (var oi=0;oi<obj_init.length;oi++){
  16.     if (obj_init[oi].className=="xx"){obj_init[oi].style.height=mh + "px";}
  17. }
  18. }
  19. function toggle(o){
  20.   if (!o.tid)o.tid = "_" + Math.random() * 100;
  21.   if (!window.toggler)window.toggler = {};
  22.   if (!window.toggler[o.tid]){
  23.     window.toggler[o.tid]={
  24.       obj:o,
  25. //      maxHeight:o.offsetHeight,
  26.       maxHeight:caiying2007,
  27.       minHeight:mh,
  28.       timer:null,
  29.       action:-1
  30.     };
  31.   }
  32.   o.style.height = o.offsetHeight + "px";
  33.   if (window.toggler[o.tid].timer)clearTimeout(window.toggler[o.tid].timer);
  34.   window.toggler[o.tid].action *= -1;
  35.   window.toggler[o.tid].timer = setTimeout("anim('"+o.tid+"')",ms );
  36. }
  37. function anim(id){
  38.   var t = window.toggler[id];
  39.   var o = window.toggler[id].obj;
  40.   if (t.action < 0){
  41.     if (o.offsetHeight <= t.minHeight){
  42.       clearTimeout(t.timer);
  43.       return;
  44.     }
  45.   }
  46.   else{
  47.     if (o.offsetHeight >= t.maxHeight){
  48.       clearTimeout(t.timer);
  49.       return;
  50.     }
  51.   }
  52.   o.style.height = (parseInt(o.style.height, 10) + t.action * step) + "px";
  53.   window.toggler[id].timer = setTimeout("anim('"+id+"')",ms );
  54. }
  55. </script>
  56. <style type="text/css">
  57. div.xx{border:solid 1px;overflow:hidden;height:200px}
  58. div.xx h5{border:solid 1px;border-width:0 0 1px;padding:0;margin:0;height:30px;line-height:30px;cursor:pointer;background:#eee;}
  59. </style>
  60. </head>
  61. <body>
  62. <div class="xx"><h5 onclick="toggle(this.parentNode);" >伸缩效果</h5>
  63. <p>内容</p>
  64. <p>内容</p>
  65. <p>内容</p>
  66. <p>内容</p>
  67. </div>
  68. <div class="xx"><h5 onclick="toggle(this.parentNode)">伸缩效果</h5>
  69. <p>sdf容</p>
  70. <p>sdf容</p>
  71. <p>sf容</p>
  72. <p>sfd容</p>
  73. </div>
  74. <script>
  75. </script>
  76. </body>
  77. </html>
复制代码
第三个代码

  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
  4. <style>
  5. body{
  6.         margin:0px;
  7.         font:normal 12px 宋体;
  8.         background: #999999;
  9. }
  10. table{border:0px;}
  11. td{font:normal 12px 宋体; }
  12. img{vertical-align:middle; border:0px;}
  13. .sec_menu{border-left:1px solid #808080; border-right:1px solid #808080;  
  14. border-bottom:1px solid #808080; overflow:hidden; background:#FFCC99;}
  15. .menu_title{background-color: #CC6600}
  16. .menu_title span{color:#FFFFFF;}
  17. .menu_title2{background-color: #FF9900}
  18. .menu_title2 span{color:#C8C8C8; }
  19. .showtitle{position:relative; top:-2px; left:-6px; border:1pt solid #C3D4E7;
  20. z-index:0; height:26; background-color: #0080C0; padding-top:5; padding-left:5}
  21. .alp{FILTER: alpha(opacity=0,finishopacity=100,style=1,startx=0,starty=5,
  22. finishx=250,finishy=85}
  23. .txt1{font-size:9pt; color:#CCCCCC;}
  24. </style>
  25. <SCRIPT LANGUAGE="JavaScript">
  26. <!--
  27. function menuShow(MenuId,maxh,MenuId2,arrow){
  28. if(MenuId.style.pixelHeight<maxh)  {
  29.     MenuId.style.pixelHeight+=maxh/20;
  30.     MenuId.filters.alpha.opacity+=5;
  31.     arrow.innerHTML="<FONT face=webdings>6</span>"
  32. if(MenuId.style.pixelHeight==maxh/10)
  33.    MenuId.style.display="block";
  34.    myMenuId=MenuId;
  35.    myMaxh=maxh;
  36.    myMenuId2=MenuId2;
  37.    myarrow=arrow
  38. setTimeout("menuShow(myMenuId,myMaxh,myMenuId2,myarrow)","5");
  39.   }
  40. }
  41. function menuHide(MenuId,maxh,MenuId2,arrow){
  42.   if(MenuId.style.pixelHeight>0)  {
  43.   if(MenuId.style.pixelHeight==maxh/20)
  44.    MenuId.style.display="none";
  45.    MenuId.style.pixelHeight-=maxh/20;
  46.    MenuId.filters.alpha.opacity-=5;
  47.    arrow.innerHTML="<FONT face=webdings>4</span>"
  48. myMenuId=MenuId;
  49. myMaxh=maxh
  50. myMenuId2=MenuId2;
  51. myarrow=arrow
  52. setTimeout("menuHide(myMenuId,myMaxh,myMenuId2,myarrow)","5");
  53.   }
  54.   else
  55.     if(whichContinue)
  56.    whichContinue.click();
  57. }
  58. function menuChange(MenuId,maxh,MenuId2,arrow){
  59.   if(MenuId.style.pixelHeight){
  60. menuHide(MenuId,maxh,MenuId2,arrow);
  61. whichOpen="";
  62. whichcontinue="";
  63.   }
  64.   else
  65.     if(whichOpen) {
  66.    whichContinue=MenuId2;
  67.       whichOpen.click();
  68. }
  69. else
  70. {
  71.    menuShow(MenuId,maxh,MenuId2,arrow);
  72.    whichOpen=MenuId2;
  73.    whichContinue="";
  74. }
  75. }
  76. function MM_preloadImages() { //v3.0
  77.   var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
  78.     var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
  79.     if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
  80. }
  81. //-->
  82. </SCRIPT>
  83. <title>Cattom</title>
  84. <link href="link.css" rel="stylesheet" type="text/css">
  85. </head>
  86. <script language="JavaScript">  
  87. nereidFadeObjects = new Object();
  88. nereidFadeTimers = new Object();
  89. function nereidFade(object, destOp, rate, delta){
  90. if (!document.all)
  91. return
  92.     if (object != "[object]"){  //提取串值
  93.         setTimeout("nereidFade("+object+","+destOp+","+rate+","+delta+")",0);
  94.         return;
  95.     }
  96.     clearTimeout(nereidFadeTimers[object.sourceIndex]);
  97.     diff = destOp-object.filters.alpha.opacity;
  98.     direction = 1;
  99.     if (object.filters.alpha.opacity > destOp){
  100.         direction = -1;
  101.     }
  102.     delta=Math.min(direction*diff,delta);
  103.     object.filters.alpha.opacity+=direction*delta;
  104.     if (object.filters.alpha.opacity != destOp){
  105.         nereidFadeObjects[object.sourceIndex]=object;
  106.         nereidFadeTimers[object.sourceIndex]=setTimeout("nereidFade(nereidFadeObjects["+object.sourceIndex+"],"+destOp+","+rate+","+delta+")",rate);
  107.     }
  108. }
  109. </script>
  110. <body>
  111. <script language=javascript>
  112.   var whichOpen=menuTitle1;
  113.   var whichContinue="";
  114. </script>
  115. <div id="Layer1" style="position:absolute; left:0px; top:350px; width:111px; height:102px; z-index:1">  
  116.   <table cellpadding=0 cellspacing=0 width=150
  117. style="border-top:1pt solid black">
  118.   <tr style="cursor:hand;">
  119. <td height=18 class=menu_title onmouseover="this.className='menu_title2'" onmouseout="this.className='menu_title'"  
  120. id=menuTitle1 onclick="menuChange (menu1,120,menuTitle1,arrow1);"> <span><span id=arrow1><FONT face="webdings">4</span>
  121. ::动漫同人志::</span></td></tr><tr><td><div class=sec_menu style="width:150;height:0; filter:alpha(Opacity=0);display:none;" id=menu1>
  122. <table cellpadding=0 cellspacing=0 align=center width=135 style="position:relative;top:10px;">
  123. <tr>
  124.               <td height=20><a href="rhdm.htm">:::日韩动漫:::</a></td>
  125.             </tr>
  126. <tr>
  127.               <td height=20><a href="gtdm.htm">:::港台动漫:::</a></td>
  128.             </tr>
  129. <tr>
  130.               <td height=20><a href="dldm.htm">:::大陆动漫:::</a></td>
  131.             </tr>
  132. <tr>
  133.               <td height=20><a href="ycdm.htm">:::原创动漫:::</a></td>
  134.             </tr>
  135. <tr>
  136.               <td height=20><a href="yqlj.htm">:::友情链接:::</a></td>
  137.             </tr>
  138. </table></div></td></tr></table>
  139. <table cellpadding=0 cellspacing=0 width=150
  140. style="border-top:1pt solid black">
  141.   <tr style="cursor:hand;">
  142. <td height=18 class=menu_title onmouseover="this.className='menu_title2'" onmouseout="this.className='menu_title'"  
  143. id=menuTitle2 onclick="menuChange (menu2,120,menuTitle2,arrow2);"> <span><span id=arrow2><FONT face="webdings">4</span>
  144. ::动漫音乐::</span></td></tr><tr><td><div class=sec_menu style="width:150;height:0; filter:alpha(Opacity=0);display:none;" id=menu2>
  145. <table cellpadding=0 cellspacing=0 align=center width=135 style="position:relative;top:10px;">
  146. <tr>
  147.               <td height=20><a href="rhdmyy.htm">::日韩动漫音乐::</a></td>
  148.             </tr>
  149. <tr>
  150.               <td height=20><a href="gtdmyy.htm">::港台动漫音乐::</a></td>
  151.             </tr>
  152. <tr>
  153.               <td height=20><a href="dldmyy.htm">::大陆动漫音乐::</a></td>
  154.             </tr>
  155. <tr>
  156.               <td height=20><a href="dmyyk.htm">::动漫音乐库::</a></td>
  157.             </tr>
  158. <tr>
  159.               <td height=20><a href="wydb.htm">:::网友点播:::</a></td>
  160.             </tr>
  161. </table></div></td></tr></table>
  162. <table cellpadding=0 cellspacing=0 width=150
  163. style="border-top:1pt solid black; border-bottom:1pt solid black;">
  164.   <tr style="cursor:hand;"><td height=18 class=menu_title onmouseover="this.className='menu_title2'" onmouseout="this.className='menu_title'"   
  165. id=menuTitle3 onclick="menuChange(menu3,140,menuTitle3,arrow3);">
  166. <span><span id=arrow3><FONT face="webdings">4</span>
  167. ::网页123::</span></td></tr><tr><td>
  168. <div class=sec_menu style="width:150;height:0;
  169. filter:alpha(Opacity=0); display:none;" id=menu3>
  170. <table cellpadding=0 cellspacing=0 align=center width=135 style="position:relative; top:10px;">
  171. <tr><td height=20>::网页基础::</td></tr>
  172. <tr><td height=20>::网页进阶::</td></tr>
  173. <tr><td height=20>::网页高手::</td></tr>
  174. <tr><td height=20>::网页脚本::</td></tr>
  175. <tr><td height=20>::网页理念::</td></tr>
  176. <tr><td height=20>::网页源件::</td></tr>
  177. </table></div></td></tr></table>
  178. <table cellpadding=0 cellspacing=0 width=150
  179. style="border-top:1pt solid black; border-bottom:1pt solid black;">
  180.   <tr style="cursor:hand;"><td height=18 class=menu_title onmouseover="this.className='menu_title2'" onmouseout="this.className='menu_title'"   
  181. id=menuTitle4 onclick="menuChange(menu4,140,menuTitle4,arrow4);">
  182. <span><span id=arrow4><FONT face="webdings">4</span>
  183. ::兄弟站点::</span></td></tr><tr><td>
  184. <div class=sec_menu style="width:150;height:0;
  185. filter:alpha(Opacity=0); display:none;" id=menu4>
  186. <table cellpadding=0 cellspacing=0 align=center width=135 style="position:relative; top:10px;">
  187. <tr><td height=20>征集中...</td></tr>
  188. <tr><td height=20>征集中...</td></tr>
  189. <tr><td height=20>征集中...</td></tr>
  190. <tr><td height=20>征集中...</td></tr>
  191. <tr><td height=20>征集中...</td></tr>
  192. <tr><td height=20>征集中...</td></tr>
  193. </table></div></td></tr></table></div>
  194. </body>
  195. </html>
复制代码
第四个代码

  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
  2. "http://www.w3.org/TR/html4/loose.dtd">
  3. <html>
  4. <head>
  5. <title>tree menu by jiarry</title>
  6. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  7. <script language="JavaScript" type="text/JavaScript">
  8. <!--//made by jiarry.126.com Aug.27 2004
  9. function showhide_obj(obj,icon)
  10. {
  11. //objStr=obj.toString();     
  12. //alert(objStr)
  13. /*objStr=2;
  14. a=objStr.toString()+5;
  15. b=objStr+5
  16. alert(a);alert(b);
  17. */
  18. if (obj.style.display=="none")  
  19.   {     
  20.     div_list = document.all.tags("div"); //指定文档中的对象为div,以适用于IE;   
  21.     for (i=0; i< div_list.length; i ++) {
  22.       thisDiv = div_list[i];  
  23.       if(thisDiv.id.indexOf("title")!=-1)//当文档div中的id含有list时,与charAt类似;
  24.       {
  25.       //if(obj.id!=obj)//该div 的id又非选中的obj,设置该div的style为none
  26.       //{
  27.       thisDiv.style.display="none";
  28.      // }
  29.       }
  30.     }  
  31.      
  32.      
  33.     myfont=document.all.tags("font");
  34.    for(i=0;i<myfont.length;i++)
  35.     {
  36.     thisfont = myfont[i];
  37.     if(thisfont.id.indexOf("icon")!=-1 && icon.id!=icon)
  38.     {   
  39.     //alert(thisfont.id)
  40.     thisfont.innerHTML="+";
  41.      }
  42.    }
  43.     icon.innerHTML="-";
  44.     obj.style.display="";  
  45. }
  46. else
  47.   {
  48.       icon.innerHTML="+";
  49.       obj.style.display="none";
  50.       }
  51. }
  52. function set_initialization(obj,img)
  53. {//设置初始状态,打开一个层;
  54.    obj.style.display="";
  55.    img.src="images/icon/minus.gif";
  56.    }
  57. //
  58. function show_this(obj)
  59. {
  60. if (obj.id==obj.id)  
  61. {
  62. //alert(obj.id)
  63.    blinkicon=document.all.tags("font");     
  64.    for(x=0;x<blinkicon.length;x++)
  65.     {
  66.     if( blinkicon[x].id.indexOf("select")!=-1 && obj.id!=obj )
  67.       {
  68.       //alert( blinkicon[x].id)
  69.        blinkicon[x].innerHTML=" ";
  70.       }
  71.     }
  72.       obj.innerHTML=">";  
  73. }
  74. else
  75. {
  76.        obj.innerHTML=" ";
  77. }
  78. }
  79. //-->
  80. </script>
  81. <style type="text/css">
  82. span{ width:100px;Height:25px;margin-left:15px;}
  83. font{font-weight:bold;}
  84. body,td{font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px;color:#333333;}
  85. div{cursor:default;border-top:1px solid gray ; border-left:1px solid gray ;border-right:1px solid gray ;background-color:#D3F7FE ;width:120px;}
  86. pre{background-color:#FFFFF1; border:1px solid gray;color:blue;font-family:verdana;Arial;padding:20px;}
  87. </style>
  88. </head>
  89. <body>
  90. <p> </p>
  91. <p> </p>
  92. <div style="line-height:25px;" onClick="showhide_obj(title1,icon1)"><font id='icon1'>+</font>栏目一</div>
  93. <div id=title1  style="background-color:#fffff3;line-height:22px;display:none;">
  94. <span id=menu1_1 onMouseOver="this.style.backgroundColor='blue'" onMouseOut="this.style.backgroundColor=''" onclick="show_this(select1_1)"><font id='select1_1'></font>菜单一</span></font>

  95. <span id=menu1_2 onclick="show_this(select1_2)"><font id='select1_2'></font>菜单二</span></font>

  96. <span id=menu1_3 onclick="show_this(select1_3)"><font id='select1_3'></font>菜单三</span></font>

  97. </div>
  98. <div style="line-height:25px;" onClick="showhide_obj(title2,icon2)"><font id='icon2'>+</font>栏目二</div>
  99. <div id=title2 style="background-color:#fffff3;line-height:22px;display:none;">
  100. <span id=menu2_1 onclick="show_this(select2_1)"><font id='select2_1'></font>菜单一</span></font>

  101. <span id=menu2_2 onclick="show_this(select2_2)"><font id='select2_2'></font>菜单二</span></font>

  102. <span id=menu2_3 onclick="show_this(select2_3)"><font id='select2_3'></font>菜单三</span></font>

  103. </div>
  104. <div style="line-height:25px;" onClick="showhide_obj(title3,icon3)"><font id='icon3'>+</font>栏目三</div>
  105. <div id=title3 style="background-color:#fffff3;line-height:22px;display:none;">
  106. <span id=menu3_1 onclick="show_this(select3_1)"><font id='select3_1'></font>菜单一</span></font>

  107. <span id=menu3_2 onclick="show_this(select3_2)"><font id='select3_2'></font>菜单二</span></font>

  108. <span id=menu3_3 onclick="show_this(select3_3)"><font id='select3_3'></font>菜单三</span></font>

  109. </div>
  110. <div style="line-height:25px;" onClick="showhide_obj(title4,icon4)"><font id='icon4'>+</font>栏目四</div>
  111. <div id=title4 style="background-color:#fffff3;line-height:22px;display:none;">
  112. <span id=menu4_1 onclick="show_this(select4_1)"><font id='select4_1'></font>菜单一</span></font>

  113. <span id=menu4_2 onclick="show_this(select4_2)"><font id='select4_2'></font>菜单二</span></font>

  114. <span id=menu4_3 onclick="show_this(select4_3)"><font id='select4_3'></font>菜单三</span></font>

  115. <span id=menu4_4 onclick="show_this(select4_4)"><font id='select4_4'></font>菜单三</span></font>

  116. <span id=menu4_5 onclick="show_this(select4_5)"><font id='select4_5'></font>菜单三</span></font>

  117. <span id=menu4_6 onclick="show_this(select4_6)"><font id='select4_6'></font>菜单三</span></font>

  118. </div>
  119. <div>
  120. <span style=" border-top:1px solid gray;width:120px;margin-left:0px;"></span>
  121. </div>
复制代码


— 产品中心

PRODUCT CENTER

— 产品中心

PRODUCT CENTER

CopyRight 2012-2017 合元网络 版权所有
公司地址:郑州市高新区升龙又一城A区2号楼2单元17楼 热线电话:15303843903 豫ICP备14027215号
快速回复 返回列表