align li tags with an auto width vs hard coding

Posted by Diver Dan on Stack Overflow See other posts from Stack Overflow or by Diver Dan
Published on 2012-04-06T05:13:29Z Indexed on 2012/04/06 5:29 UTC
Read the original article Hit count: 228

Filed under:
|

I am having trouble trying to get a group of li tags to align how I want.

I have some basic html

<div class="menu">
<ul>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
</ul>
</div>?

and some css

.menu
{
 border:solid 2px red;
 width:520px;
}

ul
{
border:solid 1px #e5e5e5;
height:40px;
margin:0 auto;
list-style:none;
width:500px;
}

li{

text-align:center;
display:inline;
margin:10px;

}

I dont want to hard code li widths for each of the elements but I would like for the li elements to take up all available space with the ul element.

What do I need to change to get the result I am looking for?

My attempt on jsfiddle

© Stack Overflow or respective owner

Related posts about html

Related posts about css