Posted By

codingforever99 on 03/07/16


Tagged

css menu html


Versions (?)

CSS HORIZONTAL LIST MENU


 / Published in: CSS
 

URL: http://function-code.blogspot.com/2016/03/css-horizontal-list-menu.html

Learn how to build simple css horizontal list menu.

  1. <style>
  2. .horizontalcssmenu ul{
  3. margin: 0;
  4. padding: 0;
  5. list-style-type: none;
  6. }
  7. /*Top level list items*/
  8. .horizontalcssmenu ul li{
  9. margin: 0;
  10. position: relative;
  11. display: inline;
  12. float: left;
  13. }
  14. /*Top level menu link items style*/
  15. .horizontalcssmenu ul li a{
  16. display: block;
  17. width: 110px; /*Width of top level menu link items*/
  18. padding: 2px 8px;
  19. border: 1px solid #202020;
  20. border-left-width: 0;
  21. text-decoration: none;
  22. background: url(menubg.gif) center center repeat-x;
  23. color: black;
  24. font: bold 13px Tahoma;
  25. }
  26. /*Sub level menu*/
  27. .horizontalcssmenu ul li ul{
  28. left: 0;
  29. top: 0;
  30. border-top: 1px solid #202020;
  31. position: absolute;
  32. display: block;
  33. visibility: hidden;
  34. z-index: 100;
  35. }
  36. /*Sub level menu list items*/
  37. .horizontalcssmenu ul li ul li{
  38. display: inline;
  39. float: none;
  40. }
  41. /* Sub level menu links style */
  42. .horizontalcssmenu ul li ul li a{
  43. width: 160px; /*width of sub menu levels*/
  44. font-weight: normal;
  45. padding: 2px 5px;
  46. background: #e3f1bd;
  47. border-width: 0 1px 1px 1px;
  48. }
  49. .horizontalcssmenu ul li a:hover{
  50. color:#000;
  51. background: url(menubgover.gif) center center repeat-x;
  52. }
  53. .horizontalcssmenu ul li ul li a:hover{
  54. color:#000;
  55. background: #cde686;
  56. }
  57. .horizontalcssmenu .arrowdiv{
  58. position: absolute;
  59. right: 0;
  60. background: transparent url(menuarrow.gif) no-repeat center left;
  61. }
  62. * html p#iepara{ /*For a paragraph (if any) that immediately follows menu, add 1em top spacing between the two in IE*/
  63. padding-top: 1em;
  64. }
  65. </style>
  66.  
  67. /* ========================== HTML CODE ===================== */
  68. <div class="horizontalcssmenu">
  69. <ul id="cssmenu1">
  70. <li style="border-left: 1px solid #202020;">
  71. <a href="http://snipplr.com/">Memu 1</a></li>
  72. <li><a href="http://function-code.blogspot.com/">Menu 2</a></li>
  73. <li><a href="#">Menu 3</a>
  74. <ul>
  75. <li><a href="http://snipplr.com/">Submenu 3-1</a></li>
  76. <li><a href="http://snipplr.com/">Submenu 3-2</a></li>
  77. <li><a href="http://snipplr.com/">Submenu 3-3</a></li>
  78. </ul>
  79. </li>
  80. </li>
  81. </ul>
  82. </div>

Report this snippet  

You need to login to post a comment.