Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS: arrange groups of similar elements in two columns

Tags:

html

css

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.)

like image 387
Marki Avatar asked Dec 12 '22 21:12

Marki


1 Answers

Yes:

.container{ position: relative }
.element{ width: 50%; float: left }
like image 167
Kerry Jones Avatar answered Feb 12 '23 10:02

Kerry Jones