Here's what I've got so far: fiddle
2 problems with it though:
- I've hard-coded the width of each
li
to33%
, which I'd prefer not to do so that I can easily add more items. - I want to put some spacing between each item (a gap in the background color), but as soon as I add a margin, one item will be bumped down a line. How do I get around that?
#main-nav {
list-style: none;
margin: 0;
padding: 0;
width: 100%;
overflow: auto;
}
#main-nav li {
float: left;
width: 33%;
height: 25px;
text-align: center;
}
#main-nav li a {
width: 100%;
display: block;
height: 100%;
line-height: 25px;
text-decoration: none;
background-color: #e0e0f0;
font-weight: bold;
color: #021020;
}
#main-nav li a:hover {
background-color: #498cd5;
color: #ddeeee;
}
<ul id="main-nav">
<li><a href="#">one</a></li>
<li><a href="#">two</a></li>
<li><a href="#">three</a></li>
</ul>