I have some data(boxes) that should display like gallery items (like in any shoping site), the issue is height of each box is not same because of its content and each row has 4 items(boxes), let say if one of the box from first has height 300px and all others has height 250px then next item in next start from end of max height in first row, i did not want it like this, i did not want these empty spaces, every box in next row should display under box from first row
here is my code
<!DOCTYPE html>
<html>
<head>
<style>
.flex-container {
width: 400px;
background-color: lightgrey;
}
.flex-item {
background-color: cornflowerblue;
width: 122px;
margin: 0 10px 10px 0;
float: left;
padding: 15px;
}
</style>
</head>
<body>
<div class="flex-container">
<div class="flex-item">flex item 1</div>
<div class="flex-item">flex item 2flex item 2flex item 2flex item 2</div>
<div class="flex-item">flex item 3</div>
<div class="flex-item">flex item 1</div>
<div class="flex-item">flex item 2</div>
<div class="flex-item">flex item 3</div>
</div>
</body>
</html>