Note that there are some explanatory texts on larger screens.

plurals
  1. POEven Flexbox product grid with left alignment
    primarykey
    data
    text
    <p>I'm trying to get a nice Flexbox grid to use with ecommerce products, but can't quite get it to do what I want.</p> <p>Here is a demo <a href="http://jsbin.com/acejes/9/edit" rel="nofollow noreferrer">http://jsbin.com/acejes/9/edit</a></p> <p>It may not be possible, I just wanted to check if there's anything else I can do.</p> <p>Here is my aim…</p> <ol> <li>Must be a percentage based grid</li> <li>The first and last column flush against the sides of the container</li> <li>The last row "floats" left</li> </ol> <p>My question is kind of similar to <a href="https://stackoverflow.com/questions/16377972/how-to-align-left-last-row-line-in-multiple-line-flexbox">How to align left last row/line in multiple line flexbox</a>, but I specifically want to use %s for the "columns" — I think it's neater and it means I know I'm going to have, say 3 columns in a row if I use a % like 32.5%</p> <p>I'm almost there, but the last line is being thrown out because of the justify-content property. I'd like the last row to be "floated" left:</p> <p><img src="https://i.stack.imgur.com/sPqZw.png" alt="Almost, except the last row"></p> <h1>Code</h1> <p>It's easier to see my code in the jsbin above, but for the sake of preservation, here is a small snapshot:</p> <pre><code>&lt;div id="flexbox"&gt; &lt;div class="column"&gt; &lt;img src="http://placehold.it/350x150" title="" alt="" /&gt; &lt;/div&gt; &lt;div class="column"&gt; &lt;p class="product-title"&gt;Decorated Pink High Heels&lt;/p&gt; &lt;p class="product-price"&gt;$25.99&lt;/p&gt; &lt;p class="product-title"&gt;Decorated Pink High Heels&lt;/p&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <h2>CSS</h2> <pre><code>* { box-sizing: border-box; } #flexbox { display: flex; flex-flow: row wrap; width: 100%; justify-content: space-between; border: 3px solid black; } #flexbox .column { width: 22%; margin-bottom: 30px; background-color: red; } img { max-width: 100%; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

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