Note that there are some explanatory texts on larger screens.

plurals
  1. POfloat:left fill same column where possible
    text
    copied!<p>I'm trying to place some divs, with this rule: Fill first column where possible, then (when first column is full) fill the second column, etc. (Please see the image below)</p> <p>This is what I want to have: (created with Paint!)</p> <p><img src="https://i.stack.imgur.com/f2wUa.png" alt="Goal"></p> <p><strong>In the image above, as you can see, first column has 1,2,3,4 and there is not enough vertical space to put 5 in the first column. So 5 should be placed on the second column...</strong></p> <p>I've tried to create something like the image above using <code>float:left</code>, but this is the result:</p> <p><img src="https://i.stack.imgur.com/4P9DP.png" alt="Current code"></p> <p>How to create something like the first image? What's wrong with my current code (which creates the second image)?</p> <hr> <p>This is my HTML code:</p> <pre><code>&lt;div class="container"&gt; &lt;div class="i1"&gt;1&lt;/div&gt; &lt;div class="i1"&gt;2&lt;/div&gt; &lt;div class="i1"&gt;3&lt;/div&gt; &lt;div class="i1"&gt;4&lt;/div&gt; &lt;div class="i2"&gt;5&lt;/div&gt; &lt;div class="i3"&gt;6&lt;/div&gt; &lt;div class="i1"&gt;7&lt;/div&gt; &lt;div class="i1"&gt;8&lt;/div&gt; &lt;/div&gt; </code></pre> <p>​And this is my CSS:</p> <pre><code>.container { overflow:scroll; width:10000px; height:200px; background:skyblue; position:absolute; } .i1,.i2,.i3 { float:left; width:100px; background:lime; border-radius: 20px; text-align:center; } .i1 { height:33px; } .i2 { height:66px; } .i3 { height:100px; } </code></pre> <p><a href="http://jsfiddle.net/AQ7bp/1/" rel="nofollow noreferrer">Fiddle of my code</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload