title: Masonry like layout with flexbox
body: <p>I am trying to achieve and Masonry like layout with flexbox only.</p>
  
  <p>i figured i would need to use a mix of columns and rows, but what i cant achieve is that the elements will all have the same distance (like stacked) below and above each other, as well as the second element in the first row wont align towards the first...is it even possible to achieve it without js? Thanks a lot</p>
  
  <p>**</p>
  
  <blockquote>
    <p>UPDATE:</p>
  </blockquote>
  
  <p>**</p>
  
  <p>I managed to pull the middle and right column up in the second row,
  so its just the second element that needs to be aligned with the middle column....so i guess js is not really neded </p>
  
  <p><a href="http://codepen.io/HendrikEng/pen/PpzYqM?editors=1100" rel="nofollow noreferrer">http://codepen.io/HendrikEng/pen/PpzYqM?editors=1100</a></p>
  
  <p>This is how it should look:  </p>
  
  <p><a href="https://i.stack.imgur.com/6P7dU.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6P7dU.png" alt="enter image description here"></a></p>
  
  <p>HTML</p>
  
  <pre><code>&lt;section&gt;
    &lt;div class="c-team-tiles"&gt;
      &lt;div class="c-team-row"&gt;
        &lt;figure class="c-team-tile"&gt;
          &lt;div class="u-margin-bottom c-team-tile__img"&gt;
            &lt;img src="http://placehold.it/390x590" alt=""&gt;
          &lt;/div&gt;
          &lt;figcaption class="c-image-tile__cpt"&gt;
            &lt;h4 class="u-margin-bottom-tiny"&gt;Name&lt;/h4&gt;
            &lt;p class="u-margin-bottom-tiny"&gt;Position&lt;/p&gt;
          &lt;/figcaption&gt;
        &lt;/figure&gt;
        &lt;figure class="c-team-tile"&gt;
          &lt;div class="u-margin-bottom c-team-tile__img"&gt;
            &lt;img src="http://placehold.it/590x390" alt=""&gt;
          &lt;/div&gt;
          &lt;figcaption class="c-image-tile__cpt"&gt;
            &lt;h4 class="u-margin-bottom-tiny"&gt;Name&lt;/h4&gt;
            &lt;p class="u-margin-bottom-tiny"&gt;Position&lt;/p&gt;
          &lt;/figcaption&gt;
        &lt;/figure&gt;
      &lt;/div&gt;
      &lt;div class="c-team-row"&gt;
        &lt;div class="c-team-column"&gt;
          &lt;figure class="c-team-tile"&gt;
            &lt;div class="u-margin-bottom c-team-tile__img"&gt;
              &lt;img src="http://placehold.it/390x330" alt=""&gt;
            &lt;/div&gt;
            &lt;figcaption class="c-image-tile__cpt"&gt;
              &lt;h4 class="u-margin-bottom-tiny"&gt;Name&lt;/h4&gt;
              &lt;p class="u-margin-bottom-tiny"&gt;Position&lt;/p&gt;
            &lt;/figcaption&gt;
          &lt;/figure&gt;
          &lt;figure class="c-team-tile"&gt;
            &lt;div class="u-margin-bottom c-team-tile__img"&gt;
              &lt;img src="http://placehold.it/390x590" alt=""&gt;
            &lt;/div&gt;
            &lt;figcaption class="c-image-tile__cpt"&gt;
              &lt;h4 class="u-margin-bottom-tiny"&gt;Name&lt;/h4&gt;
              &lt;p class="u-margin-bottom-tiny"&gt;Position&lt;/p&gt;
            &lt;/figcaption&gt;
          &lt;/figure&gt;
          &lt;figure class="c-team-tile"&gt;
            &lt;div class="u-margin-bottom c-team-tile__img"&gt;
              &lt;img src="http://placehold.it/390x590" alt=""&gt;
            &lt;/div&gt;
            &lt;figcaption class="c-image-tile__cpt"&gt;
              &lt;h4 class="u-margin-bottom-tiny"&gt;Name&lt;/h4&gt;
              &lt;p class="u-margin-bottom-tiny"&gt;Position&lt;/p&gt;
            &lt;/figcaption&gt;
          &lt;/figure&gt;
          &lt;figure class="c-team-tile"&gt;
            &lt;div class="u-margin-bottom c-team-tile__img"&gt;
              &lt;img src="http://placehold.it/390x590" alt=""&gt;
            &lt;/div&gt;
            &lt;figcaption class="c-image-tile__cpt"&gt;
              &lt;h4 class="u-margin-bottom-tiny"&gt;Name&lt;/h4&gt;
              &lt;p class="u-margin-bottom-tiny"&gt;Position&lt;/p&gt;
            &lt;/figcaption&gt;
          &lt;/figure&gt;
  
        &lt;/div&gt;
        &lt;div class="c-team-column"&gt;
          &lt;figure class="c-team-tile"&gt;
            &lt;div class="u-margin-bottom c-team-tile__img"&gt;
              &lt;img src="http://placehold.it/390x590" alt=""&gt;
            &lt;/div&gt;
            &lt;figcaption class="c-image-tile__cpt"&gt;
              &lt;h4 class="u-margin-bottom-tiny"&gt;Name&lt;/h4&gt;
              &lt;p class="u-margin-bottom-tiny"&gt;Position&lt;/p&gt;
            &lt;/figcaption&gt;
          &lt;/figure&gt;
          &lt;figure class="c-team-tile"&gt;
            &lt;div class="u-margin-bottom c-team-tile__img"&gt;
              &lt;img src="http://placehold.it/390x330" alt=""&gt;
            &lt;/div&gt;
            &lt;figcaption class="c-image-tile__cpt"&gt;
              &lt;h4 class="u-margin-bottom-tiny"&gt;Name&lt;/h4&gt;
              &lt;p class="u-margin-bottom-tiny"&gt;Position&lt;/p&gt;
            &lt;/figcaption&gt;
          &lt;/figure&gt;
          &lt;figure class="c-team-tile"&gt;
            &lt;div class="u-margin-bottom c-team-tile__img"&gt;
              &lt;img src="http://placehold.it/390x420" alt=""&gt;
            &lt;/div&gt;
            &lt;figcaption class="c-image-tile__cpt"&gt;
              &lt;h4 class="u-margin-bottom-tiny"&gt;Name&lt;/h4&gt;
              &lt;p class="u-margin-bottom-tiny"&gt;Position&lt;/p&gt;
            &lt;/figcaption&gt;
          &lt;/figure&gt;
          &lt;figure class="c-team-tile"&gt;
            &lt;div class="u-margin-bottom c-team-tile__img"&gt;
              &lt;img src="http://placehold.it/390x330" alt=""&gt;
            &lt;/div&gt;
            &lt;figcaption class="c-image-tile__cpt"&gt;
              &lt;h4 class="u-margin-bottom-tiny"&gt;Name&lt;/h4&gt;
              &lt;p class="u-margin-bottom-tiny"&gt;Position&lt;/p&gt;
            &lt;/figcaption&gt;
          &lt;/figure&gt;
          &lt;figure class="c-team-tile"&gt;
            &lt;div class="u-margin-bottom c-team-tile__img"&gt;
              &lt;img src="http://placehold.it/390x330" alt=""&gt;
            &lt;/div&gt;
            &lt;figcaption class="c-image-tile__cpt"&gt;
              &lt;h4 class="u-margin-bottom-tiny"&gt;Name&lt;/h4&gt;
              &lt;p class="u-margin-bottom-tiny"&gt;Position&lt;/p&gt;
            &lt;/figcaption&gt;
          &lt;/figure&gt;
        &lt;/div&gt;
        &lt;div class="c-team-column"&gt;
          &lt;figure class="c-team-tile"&gt;
            &lt;div class="u-margin-bottom c-team-tile__img"&gt;
              &lt;img src="http://placehold.it/390x450" alt=""&gt;
            &lt;/div&gt;
            &lt;figcaption class="c-image-tile__cpt"&gt;
              &lt;h4 class="u-margin-bottom-tiny"&gt;Name&lt;/h4&gt;
              &lt;p class="u-margin-bottom-tiny"&gt;Position&lt;/p&gt;
            &lt;/figcaption&gt;
          &lt;/figure&gt;
          &lt;figure class="c-team-tile"&gt;
            &lt;div class="u-margin-bottom c-team-tile__img"&gt;
              &lt;img src="http://placehold.it/390x330" alt=""&gt;
            &lt;/div&gt;
            &lt;figcaption class="c-image-tile__cpt"&gt;
              &lt;h4 class="u-margin-bottom-tiny"&gt;Name&lt;/h4&gt;
              &lt;p class="u-margin-bottom-tiny"&gt;Position&lt;/p&gt;
            &lt;/figcaption&gt;
          &lt;/figure&gt;
          &lt;figure class="c-team-tile"&gt;
            &lt;div class="u-margin-bottom c-team-tile__img"&gt;
              &lt;img src="http://placehold.it/390x590" alt=""&gt;
            &lt;/div&gt;
            &lt;figcaption class="c-image-tile__cpt"&gt;
              &lt;h4 class="u-margin-bottom-tiny"&gt;Name&lt;/h4&gt;
              &lt;p class="u-margin-bottom-tiny"&gt;Position&lt;/p&gt;
            &lt;/figcaption&gt;
          &lt;/figure&gt;
          &lt;figure class="c-team-tile"&gt;
            &lt;div class="u-margin-bottom c-team-tile__img"&gt;
              &lt;img src="http://placehold.it/390x330" alt=""&gt;
            &lt;/div&gt;
            &lt;figcaption class="c-image-tile__cpt"&gt;
              &lt;h4 class="u-margin-bottom-tiny"&gt;Name&lt;/h4&gt;
              &lt;p class="u-margin-bottom-tiny"&gt;Position&lt;/p&gt;
            &lt;/figcaption&gt;
          &lt;/figure&gt;
          &lt;figure class="c-team-tile"&gt;
            &lt;div class="u-margin-bottom c-team-tile__img"&gt;
              &lt;img src="http://placehold.it/390x450" alt=""&gt;
            &lt;/div&gt;
            &lt;figcaption class="c-image-tile__cpt"&gt;
              &lt;h4 class="u-margin-bottom-tiny"&gt;Name&lt;/h4&gt;
              &lt;p class="u-margin-bottom-tiny"&gt;Position&lt;/p&gt;
            &lt;/figcaption&gt;
          &lt;/figure&gt;
        &lt;/div&gt;
  
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/section&gt;
  </code></pre>
  
  <p>CSS </p>
  
  <pre><code>* {
    margin: 0;
    padding: 0;
  }
  
  .c-team-row {
    align-content: stretch;
    align-items: stretch;
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: space-between;
  }
  
  .c-team-coumn {
    align-content: stretch;
    align-items: stretch;
    display: flex;
    flex-direction: column;
    flex-wrap: wrap;
    justify-content: space-between;
  }
  
  .c-team-tile {
    align-self: auto;
    flex: 0 1 auto;
    order: 0;
  }
  </code></pre>