js - Tree of LeftMenu

本文介绍了一个使用HTML、CSS和JavaScript实现的动态网页左侧菜单栏设计方案。该方案通过鼠标悬停效果显示二级菜单,并利用JavaScript控制菜单的显示与隐藏。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

  1. <!-- LeftMenu.htm-->
  2. <html> 
  3. <head> 
  4.     <link rel="StyleSheet" href="leftTree.css" type="text/css">
  5.     <script language="javascript" src="leftTree.js"></script> 
  6. </head> 
  7. <body>
  8.     <!-- leftMenu的logo -->
  9.     <table cellpadding="0" cellspacing="0" width="158"> 
  10.         <tr style="CURSOR:hand"> 
  11.             <td height="42" valign="bottom"> 
  12.                 <img src="images/back.gif" width="160" height="30"> 
  13.             </td> 
  14.         </tr> 
  15.     </table>
  16.     <!-- leftMenu的第一级目录 -->
  17.     <table cellpadding="0" cellspacing="0" width="158"> 
  18.         <!-- 第一级目录的总目录 -->
  19.         <tr style="CURSOR:hand"> 
  20.             <td height="25" class="menu_title" onmouseover="this.className='menu_title2';" onmouseout="this.className='menu_title';" 
  21.                 background="images/title_bg_show.gif" id="menuTitle1" onclick="menuChange(menu1,80,menuTitle1);"> 
  22.                 <span>基本选项</span> 
  23.             </td> 
  24.         </tr>
  25.         <!-- 第一级目录的分目录 -->
  26.         <tr> 
  27.             <td> 
  28.                 <div class="sec_menu" style="FILTER:alpha(Opacity=100);OVERFLOW:hidden;WIDTH:158px;HEIGHT:80px" id="menu1"> 
  29.                     <table cellpadding="0" cellspacing="0" align="center" width="135" style="POSITION:relative;TOP:10px"> 
  30.                         <tr> 
  31.                             <td height="20"><a href="setLogo.aspx" target="right" onfocus="this.blur();">设置Logo</a> </td> 
  32.                         </tr> 
  33.                         <tr> 
  34.                             <td height="20"><a href="setHotNews.aspx" target="right" onfocus="this.blur();">增加热点信息</a></td> 
  35.                         </tr> 
  36.                         <tr> 
  37.                             <td height="20"> <a href="HotNewsForSearch.aspx" target="right" onfocus="this.blur();">查看热点信息</a></td> 
  38.                         </tr> 
  39.                     </table> 
  40.                 </div> 
  41.             </td> 
  42.         </tr> 
  43.     </table> 
  44.     <script language="javascript"> 
  45.         var whichOpen=menuTitle1
  46.         var whichContinue=''
  47.     </script> 
  48.     <table cellpadding="0" cellspacing="0" width="158"> 
  49.         <tr style="CURSOR:hand"> 
  50.             <td height="25" class="menu_title" onmouseover="this.className='menu_title2';" onmouseout="this.className='menu_title';" 
  51.                 background="images/title_bg_show.gif" id="menuTitle2" onclick="menuChange(menu2,120,menuTitle2);"> 
  52.                 <span>信息设置</span> 
  53.             </td> 
  54.         </tr> 
  55.         <tr> 
  56.             <td> 
  57.                 <div class="sec_menu" style="DISPLAY:none;FILTER:alpha(Opacity=0);WIDTH:158px;HEIGHT:0px" id="menu2"> 
  58.                     <table cellpadding="0" cellspacing="0" align="center" width="135" style="POSITION:relative;TOP:10px"> 
  59.                         <tr> 
  60.                             <td height="20"><a href="searchInfo.aspx?type=0" target="right" onfocus="this.blur();">查看未审核的信息</a></td> 
  61.                         </tr> 
  62.                         <tr> 
  63.                             <td height="20"><a href="searchInfo.aspx?type=1" target="right" onfocus="this.blur();">查看已审核信息</a></td> 
  64.                         </tr> 
  65.                         <tr> 
  66.                             <td height="20"><a href="put.aspx" target="right" onfocus="this.blur();">固定位置设置</a></td> 
  67.                         </tr> 
  68.                         <tr> 
  69.                             <td height="20"><a href="http://qybbs.net" onfocus="this.blur();">信体过滤规则</a></td> 
  70.                         </tr> 
  71.                         <tr> 
  72.                             <td height="20"><a href="http://qybbs.net" onfocus="this.blur();">附件过滤规则</a></td> 
  73.                         </tr> 
  74.                     </table> 
  75.                 </div> 
  76.             </td> 
  77.         </tr> 
  78.     </table> 
  79.     <table cellpadding="0" cellspacing="0" width="158"> 
  80.         <tr style="CURSOR:hand"> 
  81.             <td height="25" class="menu_title" onmouseover="this.className='menu_title2';" onmouseout="this.className='menu_title';" 
  82.                 background="images/title_bg_show.gif" id="menuTitle3" onclick="menuChange(menu3,120,menuTitle3);"> 
  83.                 <span>系统管理</span> 
  84.             </td> 
  85.         </tr> 
  86.         <tr> 
  87.             <td> 
  88.                 <div class="sec_menu" style="DISPLAY:none;FILTER:alpha(Opacity=0);WIDTH:158px;HEIGHT:0px" id="menu3"> 
  89.                     <table cellpadding="0" cellspacing="0" align="center" width="135" style="POSITION:relative;TOP:10px"> 
  90.                         <tr> 
  91.                             <td height="20"><a href="http://qybbs.net" onfocus="this.blur();">用户管理</a></td> 
  92.                         </tr> 
  93.                         <tr> 
  94.                             <td height="20"><a href="http://qybbs.net" onfocus="this.blur();">进程管理</a></td> 
  95.                         </tr> 
  96.                         <tr> 
  97.                             <td height="20"><a href="http://qybbs.net" onfocus="this.blur();">主机运行状态</a></td> 
  98.                         </tr> 
  99.                         <tr> 
  100.                             <td height="20"><a href="http://qybbs.net" onfocus="this.blur();">数据备份</a></td> 
  101.                         </tr> 
  102.                         <tr> 
  103.                             <td height="20"><a href="http://qybbs.net" onfocus="this.blur();">垃圾目录管理</a></td> 
  104.                         </tr> 
  105.                     </table> 
  106.                 </div> 
  107.             </td> 
  108.         </tr> 
  109.     </table> 
  110.     <table cellpadding="0" cellspacing="0" width="158"> 
  111.         <tr style="CURSOR:hand"> 
  112.             <td height="25" class="menu_title" onmouseover="this.className='menu_title2';" onmouseout="this.className='menu_title';" 
  113.                 background="images/title_bg_show.gif" id="menuTitle4" onclick="menuChange(menu4,140,menuTitle4);"> 
  114.                 <span>系统统计</span> 
  115.             </td> 
  116.         </tr> 
  117.         <tr> 
  118.             <td> 
  119.                 <div class="sec_menu" style="DISPLAY:none;FILTER:alpha(Opacity=0);WIDTH:158px;HEIGHT:0px" id="menu4"> 
  120.                     <table cellpadding="0" cellspacing="0" align="center" width="135" style="POSITION:relative;TOP:10px"> 
  121.                         <tr> 
  122.                             <td height="20"><a href="http://qybbs.net" onfocus="this.blur();">IP过滤统计</a></td> 
  123.                         </tr> 
  124.                         <tr> 
  125.                             <td height="20"><a href="http://qybbs.net" onfocus="this.blur();">信封过滤统计</a></td> 
  126.                         </tr> 
  127.                         <tr> 
  128.                             <td height="20"><a href="http://qybbs.net" onfocus="this.blur();">信头过滤统计</a></td> 
  129.                         </tr> 
  130.                         <tr> 
  131.                             <td height="20"><a href="http://qybbs.net" onfocus="this.blur();">信体过滤统计</a></td> 
  132.                         </tr> 
  133.                         <tr> 
  134.                             <td height="20"><a href="http://qybbs.net" onfocus="this.blur();">附件过滤统计</a></td> 
  135.                         </tr> 
  136.                         <tr> 
  137.                             <td height="20"><a href="http://qybbs.net" onfocus="this.blur();">动态规则统计</a></td> 
  138.                         </tr> 
  139.                     </table> 
  140.                 </div> 
  141.             </td> 
  142.         </tr> 
  143.     </table> 
  144.     <table cellpadding="0" cellspacing="0" width="158"> 
  145.         <tr style="CURSOR:hand"> 
  146.             <td height="25" class="menu_title" background="images/title_bg_quit.gif"> 
  147.                 <a href="managerLogin.aspx" target="_parent"> 
  148.                 <span> 退出系统</span></a> 
  149.             </td> 
  150.         </tr> 
  151.     </table> 
  152. </body> 
  153. </html> 

 

  1. <!-- LeftMenu.css -->
  2. body {
  3.     background:#799AE1;
  4.     margin:0px;
  5.     font:normal 12px 宋体;
  6. }
  7. table {
  8.     border:0px;
  9. }
  10. td {
  11.     font:normal 12px 宋体;
  12. }
  13. img {
  14.     vertical-align:bottom;
  15.     border:0px;
  16. }
  17. a {
  18.     font:normal 12px 宋体;
  19.     color:#215DC6;
  20.     text-decoration:none;
  21. }
  22. a:hover {
  23.     color:#428EFF 
  24. }
  25. .sec_menu {
  26.     border-left:1px solid white;
  27.     border-right:1px solid white;
  28.     border-bottom:1px solid white;
  29.     overflow:hidden;
  30.     background:#D6DFF7;
  31. }
  32. .menu_title {}
  33. .menu_title span {
  34.     position:relative;
  35.     top:2px;
  36.     left:8px;
  37.     color:#215DC6;
  38.     font-weight:bold;
  39.     
  40. }
  41. .menu_title2 {}
  42. .menu_title2 span {
  43.      position:relative;
  44.     top:2px;
  45.     left:8px;
  46.     color:#428EFF;
  47.     font-weight:bold;
  48. }

 

  1. <!-- LeftMenu.js -->
  2. function menuShow(obj,maxh,obj2){
  3.     if(obj.style.pixelHeight<maxh){     
  4.         obj.style.pixelHeight+=maxh/20;     
  5.         obj.filters.alpha.opacity+=5;   
  6.         obj2.background="images/title_bg_hide.gif";     
  7.         if(obj.style.pixelHeight==maxh/10)
  8.         obj.style.display='block';      
  9.         myObj=obj;      
  10.         myMaxh=maxh;        
  11.         myObj2=obj2;        
  12.         setTimeout('menuShow(myObj,myMaxh,myObj2)','5');        
  13.     }
  14. }
  15. function menuHide(obj,maxh,obj2){
  16.     if(obj.style.pixelHeight>0) {   
  17.         if(obj.style.pixelHeight==maxh/20)
  18.         obj.style.display='none';   
  19.         obj.style.pixelHeight-=maxh/20; 
  20.         obj.filters.alpha.opacity-=5;       
  21.         obj2.background="images/title_bg_show.gif";     
  22.         myObj=obj;      
  23.         myMaxh=maxh
  24.         myObj2=obj2;        
  25.         setTimeout('menuHide(myObj,myMaxh,myObj2)','5');                
  26.     } else if(whichContinue)
  27.         whichContinue.click();
  28. }
  29. function menuChange(obj,maxh,obj2){
  30.     if(obj.style.pixelHeight){      
  31.         menuHide(obj,maxh,obj2);        
  32.         whichOpen='';       
  33.         whichcontinue='';               
  34.     }else if(whichOpen){    
  35.         whichContinue=obj2; 
  36.         whichOpen.click();      
  37.     }else { 
  38.         menuShow(obj,maxh,obj2);        
  39.         whichOpen=obj2;     
  40.         whichContinue='';               
  41.     }   
  42. }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值