OsakaWebbie
Programmer
I'm trying to bring some old crappy table-layout-style code into the 21st century, but I have a quandry. I want to make a simple horizontal menu (just text - no fancy background graphics or anything) using an unordered list. It has been done a million times before:
I don't want to specify a fixed height for the ul tag, because the code is dynamically created, so the number of menu items can change; also, the user might enlarge his font size. I just want the menu items to flow freely within the box, wrapping to two or even three lines as needed, and have the box stay around the contents. But in order to get the list to be horizontal, I have to specify "float:left", and then the black box disappears because it is no longer constrained by the contents.
Any suggestions? This kind of thing was so easy with tables - I really want to do the pure CSS thing, but sometimes it's hard.
Code:
<ul class="nav">
<li><a href="somewhere">Somewhere</a></li>
<li><a href="elsewhere">Elsewhere</a></li>
...several more...
</ul>
-----------------------------------------------
ul.nav {
width:750px;
background-color:black;
text-align:center;
vertical-align:middle;
}
ul.nav li {
//float:left;
}
ul.nav li a {
padding: 2px 10px 2px 10px;
margin: 0;
display: block;
color: LightSteelBlue;
font-weight: bold;
white-space:nowrap;
}
Any suggestions? This kind of thing was so easy with tables - I really want to do the pure CSS thing, but sometimes it's hard.