0

Is it possible to create a flexbox layout with wrapping children and aligning them to the top?

.container {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
}

.container .element {
  flex: 0 0 auto;
}

creates this:

current example

but my plan is to achieve this:

wanted example

thde
  • 115
  • 6

1 Answers1

0

.container {
  border: 1px solid black;
  padding: 10px;
  height: 250px;
  
  display: flex;
  flex-wrap: wrap;
  flex-direction: column;
  align-content: flex-start;
  
  overflow: hidden;
  resize: both;
}

.container div {
  border: 5px solid #AAA;
  background-color: #DDD;
  margin: 3px;
  height: 100px;
  width: 50px;
}

.container div:nth-child(3n) {
  height: 40px;
}
<div>
  <div class="container">
    <div></div><div></div><div></div>
    <div></div><div></div><div></div>
    <div></div><div></div><div></div>
  </div>
</div>
Some Text
SirPilan
  • 4,649
  • 2
  • 13
  • 26