1

Is it possible to specifically do this to div elements:

enter image description here

<span class="wrap">
  <div></div>
  <div></div>
  <div class="big"></div>
  <div></div>
  <div></div>

  <div class="big"></div>
  <div></div>
  <div></div>
  <div></div>
  <div></div>
</span>

With flexbox? Here is a fiddle where I've been playing around but couldn't get it to work:

https://jsfiddle.net/kwqp4mmj/

And is it possible to make them repeat every 10 divs?

Michael Benjamin
  • 346,931
  • 104
  • 581
  • 701
capvidel
  • 359
  • 3
  • 14

1 Answers1

3

This is possible with nested flexboxes:

flex-container {
  display: flex;
}
flex-item {
  flex-grow: 1;
  height: 200px;
  margin: 0 5px;
  display: flex;
  flex-direction: column;
}
.big {
  flex: 0 0 40%;
  background-color: black;
}
div {
  flex-grow: 1;
  background-color: black;
}
div + div { margin-top: 10px; }
<flex-container>
  <flex-item>
    <div></div>
    <div></div>
  </flex-item>
  <flex-item class="big"></flex-item>
  <flex-item>
    <div></div>
    <div></div>
  </flex-item>
</flex-container>

<br><hr><br>

<flex-container>
  <flex-item class="big"></flex-item>
  <flex-item>
    <div></div>
    <div></div>
  </flex-item>
  <flex-item>
    <div></div>
    <div></div>
  </flex-item>
</flex-container>

jsFiddle

Michael Benjamin
  • 346,931
  • 104
  • 581
  • 701