• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

打造最美CSS多级下拉横向导航菜单代码

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文实例为大家分享了纯CSS实现多级下拉横向导航菜单代码,供大家参考,具体内容如下

先看看效果图:

实现代码:

CSS代码:

CSS Code复制内容到剪贴板
  1. <style type="text/css">   
  2. /* for this demo only */  
  3. #backgroundHolder { width:750pxheight:500pxpadding-top:10pxmargin:0 auto; }   
  4. /* ---------------------------------------------------------------------------- */  
  5. /* default styling */  
  6. .nav, .nav ul { list-style-type:nonemargin:0; padding:0; }   
  7. .nav a { text-decoration:none; }   
  8. .nav { font-familyarialsans-seriffont-size:12pxwidth:650pxmargin:0 auto; }   
  9. /* style the links */  
  10. .nav a { background:url(ulmulti3/box.gif) no-repeat rightright center; }   
  11. .nav a.top { background:url(ulmulti3/box.gif) no-repeat rightright top; }   
  12. .nav a.top2 { background:url(ulmulti3/box2.gif) no-repeat rightright top; }   
  13. .nav a.bottombottom { background:url(ulmulti3/box.gif) no-repeat rightright bottombottom; }   
  14. .rightright ul ul a { background:url(ulmulti3/box3.gif) no-repeat rightright center; }   
  15. .rightright ul ul a.top2 { background:url(ulmulti3/box3.gif) no-repeat rightright top; }   
  16. .rightright ul ul a.bottombottom { background:url(ulmulti3/box3.gif) no-repeat rightright bottombottom; }   
  17. /* style the <b> element so that is does not affect the size of the link */  
  18. .nav a b { color:#ffffont-weight:normaldisplay:blockpadding:5px 10px 5px 15px; }   
  19. .nav .fly .main b { backgroundtransparent url(ulmulti3/arrow.gif) no-repeat 117px 9px; }   
  20. .nav .down b { backgroundtransparent url(ulmulti3/arrow2.gif) no-repeat 115px 11px; }   
  21. .nav .rightright ul b { text-align:rightright; }   
  22. .nav .rightright ul ul b { padding5px 15px 5px 10px; }   
  23. .nav .rightright ul .main b { backgroundtransparent url(ulmulti3/arrow3.gif) no-repeat 15px 9pxtext-align:rightright; }   
  24. .nav .rightright ul ul .main b { backgroundtransparent url(ulmulti3/arrow3.gif) no-repeat 5px 9pxtext-align:rightright; }   
  25. /* HEIGHT */  
  26. .nav ul ul { top:-24px; } /* position the top of the flyout first sub menus */  
  27. .nav ul ul ul { top:-25px; } /* position the top of the flyout second and third sub menus */  
  28. .nav ul.two { top:-40px; } /* position the top of the flyout sub menus with previous text on two lines */  
  29. /* WIDTH change this WITH CARE to suit your requirements */  
  30.     
  31. /*set the link width here*/  
  32. .nav .drop, .nav a { width:130px; }   
  33. .nav ul li { max-width:130px; } /* fix for IE8 */  
  34. /* set the left flyout position here */  
  35. .nav ul ul { left:130px; }   
  36. /* set the right flyout position here */  
  37. .nav li.rightright ul ul { left:autorightright:120px; }   
  38. .nav li.rightright ul ul ul { left:autorightright:130px; }   
  39. /* make this WIDTH - 1px */ /* or WIDTH - 0.063em if using em sizing */  
  40. .nav a { margin-right:-129px; }   
  41. /* ---------------------------------------------------------------------------- */  
  42.     
  43. /* DO NOT CHANGE ANYTHING BELOW */  
  44. .nav li { float:left; } /* fixes IE bugs, and allows for clearing */  
  45. .nav ul { float:leftposition:relativez-index:20; } /* necessary for float drop and to stack the <ul>s */  
  46. .nav ul li { clear:left; } /* must clear the floated list item inside sublist */  
  47. .nav a { position:relativedisplay:block; } /* needs to have a position, to be above the rest */  
  48. .nav a.main { float:left/* necessary for float drop */ margin-top:10000px; } /* bring the top level links back into view */  
  49. .nav .drop, .nav .fly { margin-top:-10000px; } /* hide the sub links and their containers, opera has low upper limits */  
  50. .nav ul { margin-bottom:-5000px; } /* avoid any interaction between the subs, can be any large size */  
  51. /* The bit that does ALL the work to bring the sub menus into view */  
  52.     
  53. .nav a:hover, .nav a:focus, .nav a:active { margin-right:0; z-index:10; outline:0; }   
  54. .nav a:hover b, .nav a:focus b, .nav a:active b { color:#000cursor:pointer; } /* this is for keyboard tabbing color change */  
  55. /* OPERA fix */  
  56. .nav ul:hover, .nav ul ul:hover { clear:left; } /* to stop intermittent sub link :hover problems */  
  57.     
  58. /* ---------------------------------------------------------------------------- */  
  59. </style>   
  60. <!--[if lte IE 7]>   
  61. <style type="text/css">   
  62. /* bug fixes for IE7 and lower - DO NOT CHANGE */  
  63. .nav .fly {width:99%;} /* make each flyout 99% of the prevous level */  
  64. a:active {} /* requires a blank style for :active to stop it being buggy */  
  65. </style>   
  66.   

html代码:

XML/HTML Code复制内容到剪贴板
  1. <body>  
  2. <div id="backgroundHolder">  
  3.   <ul class="nav">  
  4.     <li class="drop"><a class="main top" href="#url"><b>Home</b></a></li>  
  5.     <li class="drop"><a class="main down top" href="#url"><b>Equipment</b></a>  
  6.       <ul>  
  7.         <li class="fly"><a class="main" href="#url"><b>Cameras</b></a>  
  8.           <ul>  
  9.             <li><a class="top2" href="#url"><b>Film Type</b></a></li>  
  10.             <li><a href="#url"><b>Compact</b></a></li>  
  11.             <li><a href="#url"><b>Polaroid</b></a></li>  
  12.             <li><a href="#url"><b>Digital</b></a></li>  
  13.             <li class="fly"><a class="main" href="#url"><b>Digital SLR</b></a>  
  14.               <ul>  
  15.                 <li><a class="top2" href="#url"><b>Canon</b></a></li>  
  16.                 <li><a href="#url"><b>Nikon</b></a></li>  
  17.                 <li><a href="#url"><b>Panasonic</b></a></li>  
  18.                 <li><a class="bottom" href="#url"><b>Kodak</b></a></li>  
  19.               </ul>  
  20.             </li>  
  21.             <li><a class="bottom" href="#url"><b>Second Hand</b></a></li>  
  22.           </ul>  
  23.         </li>  
  24.         <li class="fly"><a class="main" href="#url"><b>Video Cameras & Accessories</b></a>  
  25.           <ul class="two">  
  26.             <li class="fly"><a class="main top2" href="#url"><b>Latest Models</b></a>  
  27.               <ul>  
  28.                 <li><a class="top2" href="#url"><b>Nikon</b></a></li>  
  29.                 <li><a href="#url"><b>Panasonic</b></a></li>  
  30.                 <li><a href="#url"><b>Canon</b></a></li>  
  31.                 <li><a href="#url"><b>Pentax</b></a></li>  
  32.                 <li><a class="bottom" href="#url"><b>Minolta</b></a></li>  
  33.               </ul>  
  34.             </li>  
  35.             <li><a href="#url"><b>Special Offers</b></a></li>  
  36.             <li><a class="bottom" href="#url"><b>Professional</b></a></li>  
  37.           </ul>  
  38.         </li>  
  39.         <li class="fly"><a class="main" href="#url"><b>Lenses</b></a>  
  40.           <ul>  
  41.             <li class="fly"><a class="main top2" href="#url"><b>Digital</b></a>  
  42.               <ul>  
  43.                 <li><a class="top2" href="#url"><b>Standard</b></a></li>  
  44.                 <li><a href="#url"><b>Telephoto</b></a></li>  
  45.                 <li><a href="#url"><b>Wide Angle</b></a></li>  
  46.                 <li class="fly"><a class="main" href="#url"><b>Zoom</b></a>  
  47.                   <ul>  
  48.                     <li><a class="top2" href="#url"><b>Nikon</b></a></li>  
  49.                     <li><a href="#url"><b>Pentax</b></a></li>  
  50.                     <li><a href="#url"><b>Minolta</b></a></li>  
  51.                     <li><a class="bottom" href="#url"><b>Panasonic</b></a></li>  
  52.                   </ul>  
  53.                 </li>  
  54.                 <li class="fly"><a class="main" href="#url"><b>Zoom with Macro</b></a>  
  55.                   <ul>  
  56.                     <li><a class="top2" href="#url"><b>Panasonic</b></a></li>  
  57.                     <li><a href="#url"><b>Minolta</b></a></li>  
  58.                     <li><a href="#url"><b>Pentax</b></a></li>  
  59.                     <li><a href="#url"><b>Canon</b></a></li>  
  60.                     <li><a class="bottom" href="#url"><b>Nikon</b></a></li>  
  61.                   </ul>  
  62.                 </li>  
  63.                 <li><a href="#url"><b>Fisheye</b></a></li>  
  64.                 <li><a class="bottom" href="#url"><b>x2 converters</b></a></li>  
  65.               </ul>  
  66.             </li>  
  67.             <li class="fly"><a class="main" href="#url"><b>Standard SLR</b></a>  
  68.               <ul>  
  69.                 <li><a class="top2" href="#url"><b>Canon</b></a></li>  
  70.                 <li><a href="#url"><b>Nikon</b></

    鲜花

    握手

    雷人

    路过

    鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap