I'm trying to replicate this masonry layout I did using CSS. I figured that flexbox would be a valid option to use instead of a grid system. But I run into trouble when I'm trying to align the top right and bottom right box with each other.
I've tried putting them in another container, use flex-direction: column
and align-self
on the elements I want positioned differently, without any success.
Is it even possible to do what I want to achieve using flexbox? Or should I use a different method?
Any help is much appreciated!
What I want:
Results with flexbox:
Here's my code:
.container1{
height: 420px;
display: flex;
flex-wrap: wrap;
justify-content: center;
align-items: flex-start;
}
.item{
margin:10px;
background-color: #F1F1F1;
}
.box{
height: 420px;
width: 700px;
}
.tall{
height: 420px;
width: 215px;
}
.long{
height: 215px;
width: 458px;
}
.square{
height: 215px;
width: 215px;
}
<div class="container1">
<div class="item box"></div>
<div class="item tall"></div>
<div class="item square"></div>
<div class="item long"></div>
<div class="item long"></div>
<div class="item tall"></div>
</div>