View

Dropdown nav menu without js

Note

This code using html & css is very useful if you want to display this kind of menu! go to the adress of this source to see the demo or copy paste it in a htm file…

 

  1. <!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
  2. <html xmlns=“http://www.w3.org/1999/xhtml” lang=“fr”>
  3.     <meta content=“text/html; charset=UTF-8” http-equiv=“content-type” />
  4.     <title>:: Demo dropdown nav menu without js ::</title>
  5.     <style type=“text/css”>
  6. /* ================================================================
  7. This copyright notice must be untouched at all times.
  8. The original version of this stylesheet and the associated (x)html
  9. is available at http://www.cssplay.co.uk/menus/final_drop.html
  10. Copyright (c) 2005-2008 Stu Nicholls. All rights reserved.
  11. This stylesheet and the associated (x)html may be modified in any
  12. way to fit your requirements.
  13. =================================================================== */
  14. .menu {width:745px; height:32px; position:relative; z-index:100;border-right:1px solid #000; font-family:arial, sans-serif;}
  15. /* hack to correct IE5.5 faulty box model */
  16. * html .menu {width:746px; w\idth:745px;}
  17. /* remove all the bullets, borders and padding from the default list styling */
  18. .menu ul {padding:0;margin:0;list-style-type:none;}
  19. .menu ul ul {width:149px;}
  20. /* float the list to make it horizontal and a relative positon so that you can control the dropdown menu positon */
  21. .menu li {float:left;width:149px;position:relative;}
  22. /* style the links for the top level */
  23. .menu a, .menu a:visited {display:block;font-size:12px;text-decoration:none; color:#fff; width:138px; height:30px; border:1px solid #000; border-width:1px 0 1px 1px; background:#09c; padding-left:10px; line-height:29px; font-weight:bold;}
  24. /* a hack so that IE5.5 faulty box model is corrected */
  25. * html .menu a, * html .menu a:visited {width:149px; w\idth:138px;}
  26. /* style the second level background */
  27. .menu ul ul a.drop, .menu ul ul a.drop:visited {background:#d4d8bd url(https://www.cssplay.co.uk/menus/breadcrumbs/grey-arrow.gif) no-repeat 130px center;}
  28. /* style the second level hover */
  29. .menu ul ul a.drop:hover{background:#c9ba65 url(https://www.cssplay.co.uk/menus/breadcrumbs/blue-arrow.gif) no-repeat 130px center;}
  30. .menu ul ul :hover > a.drop {background:#c9ba65 url(https://www.cssplay.co.uk/menus/breadcrumbs/blue-arrow.gif) no-repeat 130px center;}
  31. /* style the third level background */
  32. .menu ul ul ul a, .menu ul ul ul a:visited {background:#e2dfa8;}
  33. /* style the third level hover */
  34. .menu ul ul ul a:hover {background:#b2ab9b;}
  35. /* hide the sub levels and give them a positon absolute so that they take up no room */
  36. .menu ul ul {visibility:hidden;position:absolute;height:0;top:31px;left:0; width:149px;border-top:1px solid #000;}
  37. /* another hack for IE5.5 */
  38. * html .menu ul ul {top:30px;t\op:31px;}
  39. /* position the third level flyout menu */
  40. .menu ul ul ul{left:149px; top:-1px; width:149px;}
  41. /* position the third level flyout menu for a left flyout */
  42. .menu ul ul ul.left {left:-149px;}
  43. /* style the table so that it takes no ppart in the layout – required for IE to work */
  44. .menu table {position:absolute; top:0; left:0; border-collapse:collapse;;}
  45. /* style the second level links */
  46. .menu ul ul a, .menu ul ul a:visited {background:#d4d8bd; color:#000; height:auto; line-height:1em; padding:5px 10px; width:128px;border-width:0 1px 1px 1px;}
  47. /* yet another hack for IE5.5 */
  48. * html .menu ul ul a, * html .menu ul ul a:visited {width:150px;w\idth:128px;}
  49. /* style the top level hover */
  50. .menu a:hover, .menu ul ul a:hover{color:#000; background:#b7d186;}
  51. .menu :hover > a, .menu ul ul :hover > a {color:#000; background:#b7d186;}
  52. /* make the second level visible when hover on first level list OR link */
  53. .menu ul li:hover ul,
  54. .menu ul a:hover ul{visibility:visible; }
  55. /* keep the third level hidden when you hover on first level list OR link */
  56. .menu ul :hover ul ul{visibility:hidden;}
  57. /* make the third level visible when you hover over second level list OR link */
  58. .menu ul :hover ul :hover ul{ visibility:visible;}
  59. </style>
  60.   </head>
  61. <div class=“menu”>
  62. <li><a href=“../menu/index.html”>DEMOS<!–[if IE 7]>
  63. <!–>
  64. </a><!–<![endif]–>
  65. <!–[if lte IE 6]>
  66. <table><tr><td><![endif]>
  67.         <ul>
  68.         <li><a href=“../menu/zero_dollars.html”>zero dollars advertising page</a></li>
  69.         <li><a href=“../menu/embed.html”>wrapping text around images</a></li>
  70.         <li><a href=“../menu/form.html”>styled form</a></li>
  71.         <li><a href=“../menu/nodots.html”>active focus</a></li>
  72.         <li><a class=“drop” href=“../menu/hover_click.html”>hover/click with no borders<!–[if IE 7]>
  73. <!–>
  74. </a><!–<![endif]–>
  75. <!–[if lte IE 6]>
  76. <table><tr><td><![endif]>
  77.                 <ul>
  78.                         <li><a href=“../menu/form.html”>styled form</a></li>
  79.                         <li><a href=“../menu/nodots.html”>removing active/focus borders</a></li>
  80.                         <li><a href=“../menu/hover_click.html”>hover/click</a></li>
  81.                 </ul>
  82. <!–[if lte IE 6]>
  83. </td></tr></table></a><![endif]>
  84.         </li>
  85.         <li><a class=“drop” href=“../menu/shadow_boxing.html”>shadow boxing<!–[if IE 7]>
  86. <!–>
  87. </a><!–<![endif]–>
  88. <!–[if lte IE 6]>
  89. <table><tr><td><![endif]>
  90.                 <ul>
  91.                         <li><a href=“../menu/form.html”>styled form</a></li>
  92.                         <li><a href=“../menu/nodots.html”>removing active/focus borders</a></li>
  93.                         <li><a href=“../menu/hover_click.html”>hover/click</a></li>
  94.                 </ul>
  95. <!–[if lte IE 6]>
  96. </td></tr></table></a><![endif]>
  97.         </li>
  98.         <li><a class=“drop” href=“../menu/old_master.html”>image map for detailed information<!–[if IE 7]>
  99. <!–>
  100. </a><!–<![endif]–>
  101. <!–[if lte IE 6]>
  102. <table><tr><td><![endif]>
  103.                 <ul>
  104.                         <li><a href=“../menu/form.html”>styled form</a></li>
  105.                         <li><a href=“../menu/nodots.html”>removing active/focus borders</a></li>
  106.                         <li><a href=“../menu/hover_click.html”>hover/click</a></li>
  107.                 </ul>
  108. <!–[if lte IE 6]>
  109. </td></tr></table></a><![endif]>
  110.         </li>
  111.         <li><a href=“../menu/bodies.html”>fun with background images</a></li>
  112.         <li><a href=“../menu/fade_scroll.html”>fade scrolling</a></li>
  113.         <li><a href=“../menu/em_images.html”>em image sizes compared</a></li>
  114.         </ul>
  115. <!–[if lte IE 6]>
  116. </td></tr></table></a><![endif]>
  117. </li>
  118. <li><a href=“../boxes/index.html”>BOXES<!–[if IE 7]>
  119. <!–>
  120. </a><!–<![endif]–>
  121. <!–[if lte IE 6]>
  122. <table><tr><td><![endif]>
  123.         <ul>
  124.         <li><a href=“spies.html”>a coded list of spies</a></li>
  125.         <li><a href=“vertical.html”>vertical menu</a></li>
  126.         <li><a href=“expand.html”>enlarging unordered list</a></li>
  127.         <li><a href=“enlarge.html”>link images</a></li>
  128.         <li><a href=“cross.html”>non-rectangular</a></li>
  129.         <li><a href=“jigsaw.html”>jigsaw links</a></li>
  130.         <li><a href=“circles.html”>circular links</a></li>
  131.         </ul>
  132. <!–[if lte IE 6]>
  133. </td></tr></table></a><![endif]>
  134. </li>
  135. <li><a href=“../mozilla/index.html”>MOZILLA<!–[if IE 7]>
  136. <!–>
  137. </a><!–<![endif]–>
  138. <!–[if lte IE 6]>
  139. <table><tr><td><![endif]>
  140.         <ul>
  141.         <li><a href=“../mozilla/dropdown.html”>drop down menu</a></li>
  142.         <li><a href=“../mozilla/cascade.html”>cascading menu</a></li>
  143.         <li><a href=“../mozilla/content.html”>content:</a></li>
  144.         <li><a href=“../mozilla/moxbox.html”>mozzie box</a></li>
  145.         <li><a href=“../mozilla/rainbow.html”>I can build a rainbow with transparent borders</a></li>
  146.         <li><a href=“../mozilla/snooker.html”>a snooker cue using border art</a></li>
  147.         <li><a href=“../mozilla/target.html”>target practise</a></li>
  148.         <li><a href=“../mozilla/splittext.html”>two tone headings</a></li>
  149.         <li><a href=“../mozilla/shadow_text.html”>shadow text</a></li>
  150.         </ul>
  151. <!–[if lte IE 6]>
  152. </td></tr></table></a><![endif]>
  153. </li>
  154. <li><a href=“../ie/index.html”>EXPLORER</a></li>
  155. <li><a href=“../opacity/index.html”>OPACITY<!–[if IE 7]>
  156. <!–>
  157. </a><!–<![endif]–>
  158. <!–[if lte IE 6]>
  159. <table><tr><td><![endif]>
  160.         <ul>
  161.         <li><a href=“../opacity/colours.html”>a colour wheel using opaque colours</a></li>
  162.         <li><a href=“../opacity/picturemenu.html”>a menu using opacity</a></li>
  163.         <li><a href=“../opacity/png.html”>partial opacity</a></li>
  164.         <li><a href=“../opacity/png2.html”>partial opacity II</a></li>
  165.         <li><a class=“drop” href=“../menu/hover_click.html”>HOVER/CLICK<!–[if IE 7]>
  166. <!–>
  167. </a><!–<![endif]–>
  168. <!–[if lte IE 6]>
  169. <table><tr><td><![endif]>
  170.                 <ul class=“left”>
  171.                         <li><a href=“../menu/form.html”>styled form</a></li>
  172.                         <li><a href=“../menu/nodots.html”>removing active/focus borders</a></li>
  173.                         <li><a href=“../menu/hover_click.html”>hover/click</a></li>
  174.                 </ul>
  175. <!–[if lte IE 6]>
  176. </td></tr></table></a><![endif]>
  177.         </li>
  178.         </ul>
  179. <!–[if lte IE 6]>
  180. </td></tr></table></a><![endif]>
  181. </li>
  182. </ul>
  183. </div>
  184. </body>
  185. </html>

You may also like