I have a unique photo gallery setup that I'm struggling with:
As I keep adding photos, the cards in my gallery get smaller and smaller! What I really want is to show only 4 photos at a time and hide the rest, creating a sliding effect. I attempted adjusting the container width and using overflow-x: scroll, but it didn't quite produce the desired result. Is there a way to achieve this slider effect with my current gallery layout? If so, how can I do it? I've tried searching for a solution online, but most examples involve static cards and not my dynamic gallery.
.containerss {
display: flex;
width: 100%;
padding: 4% 2%;
box-sizing: border-box;
height: 86vh;
}
.box {
flex: 1;
overflow: hidden;
transition: .5s;
margin: 0 2%;
box-shadow: 0 20px 30px rgba(0, 0, 0, .1);
line-height: 0;
background-color: black;
}
.box>img {
width: 100%;
height: 100%;
object-fit: cover;
transition: .5s;
}
.box:hover {
flex: 1 1 40%;
}
.box:hover>img {
width: 100%;
height: 100%;
}
<div class="containerss">
<div class="box">
<img src="https://source.unsplash.com/1000x807" loading=lazy>
</div>
<div class="box">
<img src="https://source.unsplash.com/1000x808" loading=lazy>
</div>
<div class="box">
<img src="https://source.unsplash.com/1000x810" loading=lazy>
</div>
<div class="box">
<img src="https://source.unsplash.com/1000x802" loading=lazy>
</div>
</div>