this problem has been bothering me for some time. So I have created some visual descriptions of my problem
First here is my HTML structure I have 6 divs.. the first 3 float left and the last 3 float right. The last image shows the result I want but can't seem to get. Can someone out there help me here
EDIT// Sorry heres my HTML and CSS
<style>
.left { float:left; }
.right { float:right; }
</style>
<div id="container">
<div class="left"></div>
<div class="left"></div>
<div class="left"></div>
<div class="right"></div>
<div class="right"></div>
<div class="right"></div>
</div>
NOTE: I Cant do a left right left right left right option because Im getting my data from PHP via a Query to my database.. first query goes left second query goes right.... thanks a bunch
/EDIT
My floats result in this
This is what I want
Suppose you have another div in the middle of them. Then use this chronological order:
Or if you don't, just add another div that provide a style
clear:both
to it.Try this:
You can use CSS3
column-count
property for this. Write like this:Check this http://jsfiddle.net/UaFFP/6/
Using the :nth-child selector and clearing after 2 divs:
Live example
Otherwise use this fairly hacky method, which requires no additional markup:
Live example
column-count
is already widely supported - http://caniuse.com/#feat=multicolumn So if old browsers doesn't bother you consider using it.Add the first left div, then the first right div and after them add
<br style="clear:both">
and repeat the procedure.Edit: Here's an updated answer: