My goal is to create a responsive gallery following this tutorial. Here is my attempt on codesandbox.io
However, I'm facing an issue where only four columns are shown instead of the expected five. The image below illustrates the problem:
https://i.sstatic.net/ZijvS.jpg
Code CSS (media query not included)
#gallery {
line-height: 0;
-webkit-column-count: 5; /* split it into 5 columns */
-webkit-column-gap: 5px; /* give it a 5px gap between columns */
-moz-column-count: 5;
-moz-column-gap: 5px;
column-count: 5;
column-gap: 5px;
}
#gallery img {
width: 100% !important;
height: auto !important;
margin-bottom: 5px; /* to match column gap */
}
HTML
<body>
<div id="gallery">
<img src="https://images.unsplash.com/photo-1620920709484-995504fbecd2?ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&ixlib=rb-1.2.1&auto=format&fit=crop&w=634&q=80">
<!-- More images here -->
</div>
</body>
If you have any insights or solutions, please share them. Appreciate your help.
//EDIT I came across what seems like a great gallery example at https://codepen.io/maxvoltar/pen/eYOPdMG