The menu at the top of this site is an unordered list. I wanted to stretch the menu to fill the width of the site without setting widths and margins. Here’s how I did it.
#menu {
width: 1000px;
height: 40px;
margin: 0 0 13px 0;
padding: 7px 0 0 0;
text-align: justify;
position: relative;
z-index: 4000;
}
#menu * {
display: inline;
}
#menu span {
display: inline-block;
position: relative;
width: 100%;
height: 0;
}
#menu ul li {
text-align: center;
margin-right: 1px;
}
Then you’ll need to add
<span></span>
before the closing </ul> tag of your list.
Here’s the HTML:
<div id="menu">
<ul>
<li><a href="">home</a></li>
<li><a href="">about</a></li>
...
<li><a href="">contact</a></li>
<span></span>
</ul>