免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 3395 | 回复: 0
打印 上一主题 下一主题

JS+CSS打造简约的多级横向导航菜单 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2011-06-22 11:56 |只看该作者 |倒序浏览
JS+CSS打造简约的多级横向导航菜单
代码简介:JS+CSS打造简约的多级横向导航菜单

代码内容:

view sourceprint?
  1. <html>  

  2. <head>  

  3. <title>JS+CSS打造简约的多级横向导航菜单_网页代码站(www.webdm.cn)</title>  

  4. <style type="text/css">  

  5.    .suckerdiv ul{  

  6. margin: 0;  

  7. padding: 0;  

  8. list-style-type: none;  

  9. width: 150px; /* Width of Menu Items */  

  10. border-bottom: 1px solid #ccc;  

  11. }  

  12.       

  13. .suckerdiv ul li{  

  14. position: relative;  

  15. }  

  16.       

  17. /*1st level sub menu style */  

  18. .suckerdiv ul li ul{  

  19. left: 149px; /* Parent menu width - 1*/  

  20. position: absolute;  

  21. width: 160px; /*sub menu width*/  

  22. top: 0;  

  23. display: none;  

  24. }  

  25.    

  26. /*All subsequent sub menu levels offset */  

  27. .suckerdiv ul li ul li ul{   

  28. left: 159px; /* Parent menu width - 1*/  

  29. }  

  30.    

  31. /* menu links style */  

  32. .suckerdiv ul li a{  

  33. display: block;  

  34. color: black;  

  35. text-decoration: none;  

  36. font:12px 宋体;  

  37. background: #fff;  

  38. padding: 5px 5px;  

  39. border: 1px solid #ccc;  

  40. border-bottom: 0;  

  41. }  

  42.    

  43. .suckerdiv ul li a:visited{  

  44. color: black;  

  45. }  

  46.    

  47. .suckerdiv ul li a:hover{  

  48. color: white;  

  49. background-color: gray;  

  50. }  

  51.    

  52. .suckerdiv .subfolderstyle{  

  53. background: url(http://www.webdm.cn/images/20100918/arrow-list.gif) no-repeat center right;  

  54. }  

  55.    

  56.       

  57. /* Holly Hack for IE \*/  

  58. * html .suckerdiv ul li { float: left; height: 1%; }  

  59. * html .suckerdiv ul li a { height: 1%; }  

  60. /* End */  

  61.    

  62.    

  63.    

  64.    

  65. </style>  

  66.    

  67. <script type="text/javascript">  

  68. //SuckerTree Vertical Menu (Aug 4th, 06)  

  69. //By Dynamic Drive: http://www.dynamicdrive.com/style/  

  70.    

  71. var menuids=["suckertree1"] //Enter id(s) of SuckerTree UL menus, separated by commas  

  72.    

  73. function buildsubmenus(){  

  74. for (var i=0; i<menuids.length; i++){  

  75.   var ultags=document.getElementById(menuids[i]).getElementsByTagName("ul")  

  76.     for (var t=0; t<ultags.length; t++){  

  77.     ultags[t].parentNode.getElementsByTagName("a")[0].className="subfolderstyle"

  78.     ultags[t].parentNode.onmouseover=function(){  

  79.     this.getElementsByTagName("ul")[0].style.display="block"

  80.     }  

  81.     ultags[t].parentNode.onmouseout=function(){  

  82.     this.getElementsByTagName("ul")[0].style.display="none"

  83.     }  

  84.     }  

  85.   }  

  86. }  

  87.    

  88. if (window.addEventListener)  

  89. window.addEventListener("load", buildsubmenus, false)  

  90. else if (window.attachEvent)  

  91. window.attachEvent("onload", buildsubmenus)  

  92. </script>  

  93. </head>  

  94. <body>  

  95.    

  96. <div class="suckerdiv">  

  97. <ul id="suckertree1">  

  98. <li><a href="#">Item 1</a></li>  

  99. <li><a href="#">Item 2</a></li>  

  100. <li><a href="#">Folder 1</a>  

  101.   <ul>  

  102.   <li><a href="#">Sub Item 1.1</a></li>  

  103.   <li><a href="#">Sub Item 1.2</a></li>  

  104.   </ul>  

  105. </li>  

  106. <li><a href="#">Item 3</a></li>  

  107.    

  108. <li><a href="#">Folder 2</a>  

  109.   <ul>  

  110.   <li><a href="#">Sub Item 2.1</a></li>  

  111.   <li><a href="#">Folder 2.1</a>  

  112.     <ul>  

  113.     <li><a href="#">Sub Item 2.1.1</a></li>  

  114.     <li><a href="#">Sub Item 2.1.2</a></li>  

  115.     <li><a href="#">Sub Item 2.1.3</a></li>  

  116.     <li><a href="#">Sub Item 2.1.4</a></li>  

  117.     </ul>  

  118.   </li>  

  119. </ul>  

  120. </a>  

  121. </li>  

  122. <li><a href="#">Item 4</a></li>  

  123. </ul>  

  124. </div>  

  125. <p></p>  

  126. </body>  

  127. </html>  

  128. <br>  

  129. <p><a href="http://www.webdm.cn">网页代码站</a> - 最专业的代码下载网站 - 致力为中国站长提供有质量的代码!</p>
复制代码
代码来自:http://www.webdm.cn/webcode/b1e1 ... a-e1b5a9d85609.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP