I want to create an image slideshow, which only shows one image at a time. However, I want to use relative values for every child of the parent container, so that I can easily resize the slideshow. Every image should have the same height and width.
As I already mentioned, I only want to show one image at a time. As a result, the others images need to be hidden with overflow: hidden;. The problem is that my images do not even overflow in Firefox.
.image-slider {
height: 20rem;
width: 20rem;
}
.image-slider .main {
display: flex;
align-items: center;
}
.main .images {
display: flex;
overflow: auto;
width: 90%;
height: 100%;
}
.main .images img {
object-fit: scale-down;
width: 100%;
height: 100%;
}
<div class="image-slider">
<div class="main">
<div class="images">
<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/2/25/Red.svg/512px-Red.svg.png" />
<img src="https://upload.wikimedia.org/wikipedia/commons/thumb/f/ff/Solid_blue.svg/768px-Solid_blue.svg.png" />
</div>
</div>
</div>
I want that only the red image is displayed, and that the blue one should vanish because it should overflow. I'm pretty sure that the issue is because of my relative values, however I can't explain why. In Chrome, I achieve my desired result with the above code.
How can I create a slideshow, which is easily resizable, sets all images to the same size (regardless of the source width and height), shows only one image at a time and hides the other ones?