I’m trying to create a horizontal UL which always shows 3 items per line. The tricky part is that the items can be of varying widths. For example:
<ul class="items">
<li>
<input type="checkbox" id="work" />
Work items
</li>
<li>
<input type="checkbox" id="shopping" />
Shopping
</li>
<li>
<input type="checkbox" id="financial" />
Financial Information & Tips
</li>
</ul>
etc.
I want to do it so its essentially like using a table, where it always shows 3 items per line, and the checkbox of each item is always on the same line as its text.
How can I do it?
Here’s the current code I’m using, but it doesn’t show the items evenly, often the last checkbox ends up on line 1 and the text is pushed to the next line.
ul.items
{
text-align: center;
list-style-type: none;
width: 400px;
}
ul.items li
{
display: inline;
}
I like to use float for this
with this html:
Demo here: http://jsfiddle.net/hG3Us/