Skip to content

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