Horizontal CSS List Menu
First of all we’ll need the HTML for our list menu, this is just a normal unordered list.
1 2 3 4 5 6 7 8 9 10 | <div class="menu"><ul><li><a href="#">Homea>li><li><a href="#">Linka>li><li><a href="#">Linka>li><li><a href="#">Linka>li><li><a href="#">Linka>li>ul><br style="clear:left"/>div> |
It’s just a simple html page with an unordered list menu on. You might notice I’ve added a div called menu around the list, I like to do this as it helps me remember what part of the code does what if I ever have to go back to it.
Next we’re going to add the CSS code for the div called menu that surrounds the list.
1 2 3 | .menu{ width: 100%; background-color: #333; } |
Again this is nice and simple. The menu div will be the full width of the div it’s inside and will have a dark grey background.
Next we add the syling for the list and the list items.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | .menu ul{ margin: 0; padding: 0; float: left;}.menu ul li{ display: inline;}.menu ul li a{ float: left; text-decoration: none; color: white; padding: 10.5px 11px; background-color: #333; }.menu ul li a:visited{ color: white;}.menu ul li a:hover, .menu ul li .current{ color: #fff; background-color:#0b75b2;} |
Again it’s all pretty simple, you should be able to understand the code with a little bit of CSS knowledge. Have a tinker with the code if you’re unsure about something.
منبع: http://jamesowers.co.uk
با سلام. فرهاد هستم. فناوری اطلاعات خوندم، برنامه نویسی php , اندروید کار می کنم. تو آموزشگاه کامپیوتر هم تدریس می کنم.