Stretch horizontal ul to fit width of div
Solution 1:
This is the easiest way to do it: http://jsfiddle.net/thirtydot/jwJBd/
(or with table-layout: fixed
for even width distribution: http://jsfiddle.net/thirtydot/jwJBd/59/)
This won't work in IE7.
#horizontal-style {
display: table;
width: 100%;
/*table-layout: fixed;*/
}
#horizontal-style li {
display: table-cell;
}
#horizontal-style a {
display: block;
border: 1px solid red;
text-align: center;
margin: 0 5px;
background: #999;
}
Old answer before your edit: http://jsfiddle.net/thirtydot/DsqWr/
Solution 2:
People hate on tables for non-tabular data, but what you're asking for is exactly what tables are good at. <table width="100%">
Solution 3:
inelegant (but effective) way: use percentages
#horizontal-style {
width: 100%;
}
li {
width: 20%;
}
This only works with the 5 <li>
example. For more or less, modify your percentage accordingly. If you have other <li>
s on your page, you can always assign these particular ones a class of "menu-li" so that only they are affected.