I am using flex-wrap for responsiveness. But there is a considerable gap between first-row and second-row items. The height of the items will be dynamic. it will depend on the content of the item. The number of items is also dynamic
This is what I am looking for (Expected Output)
Currently, this is what I have.
Here are my HTML and CSS code snippet to demonstrate what I have done.
body{
display:block;
padding: 5px;
}
.container{
background: #f8f9fa;
display: flex;
flex-wrap: wrap;
justify-content: start;
align-items: start;
width: 100%;
padding: 10px;
gap:10px;
}
.item1{
width: 250px;
height: 100px;
background: #a5bdb5;
border-radius: 5px;
}
.item2{
width: 250px;
height: 150px;
background: #a5bdb5;
border-radius: 5px;
}
.item3{
width: 250px;
height: 250px;
background: #a5bdb5;
border-radius: 5px;
}
.item4{
width: 250px;
height: 50px;
background: #a5bdb5;
border-radius: 5px;
}
.item5{
width: 250px;
height: 130px;
background: #a5bdb5;
border-radius: 5px;
}
<html>
<body>
<div class="container">
<div class="item1">
</div>
<div class="item2">
</div>
<div class="item3">
</div>
<div class="item4">
</div>
<div class="item5">
</div>
</div>
</body>
</html>
if this is not possible with flex then what else i can do to achieve this?