views:

51

answers:

1

If my HTML says something along the following

<div class="container">
 <div class="element">
 </div>
 <div class="element">
 </div>
 [...]
 <div class="element">
 </div>
</div>

is it then possible to align those elements as if they were in a two-column table? I.e. with 7 elements there would be 4 rows, with the last row only having one element.

(The elements themselves have NO special classes or ids like right,left,etc.)

+9  A: 

Yes:

.container{ position: relative }
.element{ width: 50%; float: left }
Kerry
well you can't set width on an inline object, and heaps of other things that you'd normally expect from a div, so i disagree on that part, but other than that, yes, float left is the way to go.
David Hedlund
Ah, good point, edited.
Kerry
I had to set clear:both on the div after the container div but it seems to work. Didn't think it was thay easy. Thx.
Marki
Sure! Glad it helped :)
Kerry