...

View Full Version : Changing width of individual nav menu items



robinogi
05-31-2007, 05:08 AM
I'm making a horizontal nav bar, and I'd like to have everything spaced appropriately. The thing is, when I set the li width to a certain value, all of my items are the same width. I have some list items that have longer names (i.e. "Before You Come") and some short ones (i.e. "FAQ") and with the li width set at one value, "Before You Come" is crowded down to the next line, and "FAQ" has tons of space to the left and right... Is there a way to set the width of the list items individually? Thanks.

Robin

P.S. My CSS looks like this:

ul {
padding: 0;
margin: 0;
list-style: none;
position:absolute;
left:5px;
top:40px;
text-transform:uppercase;
}
li {
float: left;
position: relative;
width: 90px;
text-align:center;
}
li ul {
display: none;
position: absolute;
top: 0;
left: 0;
}
li > ul {
top: auto;
left: auto;
}
li:hover ul { display: block; clear:left; }

rmedek
05-31-2007, 08:49 AM
You could add an individual id or class to each item list, like so:

<li id="nav_one"><a href="#">page one</a></li>
<li id="nav_two"><a href="#">page two</a></li>
<li id="nav_three"><a href="#">page three</a></li>

But it might be easier just to let the list item width fit to each element and add a little padding to open it up a bit:

li {
float: left;
position: relative;
width: auto;
text-align:center;
padding: 0 1em;
}

Hope this helps…



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum