There is nothing wrong here except your browser.....

2008/05/12

Horizontal menu

Filed under: Tips & Tricks — Tags: — admin @ 9:04 pm

Here is an old trick to make horizontal menu with CSS.

First you have to make a list with UL and LI tags.

  1.  
  2. <ul class="menu">
  3.     <li><a href="http://swape.net">My homepage</a></li>
  4.     <li><a href="http://linux.org">Linux.org</a></li>
  5.     <li><a href="http://google.com">Link to google</a></li>
  6. </ul>
  7.  

Ok here is a list. Now we must make the list items to be horizontal and not vertical. So we must use CSS to set the float to be left and make the list-style: none;

  1. .menu li{ float: left; list-style: none; }

Then we must make them look like a buttons. So we add some borders and padding and margins. Then the whole CSS code look like this:

  1. .menu li{
  2. float: left;
  3. list-style: none;
  4. font: 10px Verdana, Arial, Helvetica, sans-serif;
  5. }
  6. .menu li a {
  7. display:block;
  8. padding:3px;
  9. margin:1px;
  10. border:1px solid #ccc;
  11. text-decoration:none;
  12. color:#332;
  13. background-color: #EEE;
  14. }
  15. .menu li a:hover{
  16. color:#EEE;
  17. background-color: #331;
  18. }

You can download the example file here: Horizontal CSS menu

Powered by WordPress. Design by Alireza Balouch. Top