I'm trying to make an image gallery using Django and python. I'm new to HTML and CSS and need to show the images in a grid. I want one image in a row to be the same height but different width like Deviantart's. And the number of columns should be different like shown in the image below.
I am able to display the images in a gallery, like this.
but the images are not the same height and not in order. Is there any way to achieve a gallery like in the first image?
Thank you for your time!
Update: This is the code I'm currently using.
.gallery-container {
column-count: 4;
column-gap: 5px;
margin: 20px;
}
.gallery-item {
display: inline-block;
width: 100%;
background: #1e1f26;
border-radius: 6px;
}
.gallery-item img {
display: block;
border-radius: 5px;
width: 100%;
}
<div class="gallery-container">
<div class="gallery-item">
<img src="https://images.unsplash.com/photo-1485550409059-9afb054cada4?ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=401&q=80" alt="">
</div>
<div class="gallery-item">
<img src="https://images.unsplash.com/photo-1493612276216-ee3925520721?ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=400&q=80" alt="">
</div>
<div class="gallery-item">
<img src="https://images.unsplash.com/photo-1499854413229-6d1c92ff39ef?ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=802&q=80" alt="">
</div>
<div class="gallery-item">
<img src="https://images.unsplash.com/photo-1489533119213-66a5cd877091?ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=751&q=80" alt="">
</div>
<div class="gallery-item">
<img src="https://images.unsplash.com/photo-1500462918059-b1a0cb512f1d?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=334&q=80" alt="">
</div>
<div class="gallery-item">
<img src="https://images.unsplash.com/photo-1496449903678-68ddcb189a24?ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=750&q=80" alt="">
</div>
</div>

