I'm trying to build a gallery in form of a masonry, but I can't get my head around wrapping of flexboxes?
I got a simple UL list and I've added the style needed, but things are not floating and wrapping as it should.
.masonry {
  margin: 48px -2px;
  padding-left: 0;
  list-style: none;
  align-items: flex-start;
  flex-direction: row;
  flex-wrap: wrap;
  display: flex;
}
.masonry li {
 
  height: 300px;
  flex-basis: calc(33.33% - 4px);
  margin: 2px;
  text-align: center;
  display: flex;
  
  background-color: #C9F4FF;
}
.masonry li:nth-child(1), .masonry li:nth-child(7) {
  height: 604px;
  
  background-color: #FFB4FF;
}
.masonry li:nth-child(4), .masonry li:nth-child(4) {
  flex-basis: calc(66.66% - 4px);
  background-color: #B9EDA8;
}<!-- masonry starts -->
    <ul class="masonry">
        <li> </li>
        <li> </li>
        <li> </li>
        <li> </li>
        <li> </li>
        <li> </li>
        <li> </li>
        <li> </li>
    </ul>
<!-- masonry ends -->The result looks like this, which is kinda funny :)
Maybe someone knows how to write the correct CSS to make things wrap correctly?


 
     
    
