Note that there are some explanatory texts on larger screens.

plurals
  1. POFloat divs, treat like rows
    text
    copied!<p>I have something like:</p> <pre><code>&lt;div id="container"&gt; &lt;div&gt;&lt;/div&gt; &lt;div&gt;&lt;/div&gt; &lt;div&gt;&lt;/div&gt; &lt;div&gt;&lt;/div&gt; &lt;div&gt;&lt;/div&gt; &lt;div&gt;&lt;/div&gt; &lt;/div&gt; </code></pre> <p>I've set the container to a clear fix and floated the divs inside the container, like this:</p> <p><img src="https://i.stack.imgur.com/PI6Pq.gif" alt="enter image description here"></p> <p>However, when I have additional text in a div, I'd <strong>like</strong> it to push the other divs down as if they were a row, like this:</p> <p><img src="https://i.stack.imgur.com/IhkEi.gif" alt="the divs should work like &quot;rows&quot; if possible "></p> <p>Instead, because of the floats, I'm getting something more like this:</p> <p><img src="https://i.stack.imgur.com/R3bhz.gif" alt="enter image description here"></p> <p>I'm just wondering as to the best way to go about this. I <strong>could</strong> put a wrapper around each "row", like:</p> <pre><code>&lt;div id="container"&gt; &lt;div class="row"&gt; &lt;div&gt;&lt;/div&gt; &lt;div&gt;&lt;/div&gt; &lt;div&gt;&lt;/div&gt; &lt;/div&gt; &lt;div class="row"&gt; &lt;div&gt;&lt;/div&gt; &lt;div&gt;&lt;/div&gt; &lt;div&gt;&lt;/div&gt; &lt;/div&gt; div class="row"&gt; &lt;div&gt;&lt;/div&gt; &lt;div&gt;&lt;/div&gt; &lt;div&gt;&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>But that seems to be a lot of extra non-semantic divs...plus if I am generating the divs dynamically (through a list-view in a cms) then I have to add extra code to count each multiple of three divs...</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