I have searched long and hard for this one and can't seem to find a solution.
I have a client who wants the menu text to use 100% of the width of the menu and have each menu item spaced out evenly. In other words, the left-most menu item should sit flush with the left side of the <nav>
and the right-most menu item should sit flush with the right side of the <nav>
.
I would normally set the <li>
to text-align:center;
, but that leaves space on the left side and the right side. Is there a way to accomplish this with just CSS and HTML? In my version, the left side is fine, but there is space on the right. Here is my code:
HTML:
<nav>
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">Media</a></li>
<li><a href="#">Tour</a></li>
<li><a href="#">News</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Contact</a></li>
</ul>
</nav>
CSS:
nav ul{
display: table;
table-layout: fixed;
width: 100%;
padding: 0;
100px;
}
nav ul li {
list-style-type: none;
display: table-cell;
background: gray;
}
nav ul li a {
display:block;
}
And a fiddle with the exact same thing: http://jsfiddle.net/zx4de/1/
Any help would be much appreciated. Thanks!