I'm using percentages to scale thumbnails in a gallery on my website, and I can't get object-fit: cover
to work with them. I'm trying to use object-fit
so I can get the thumbnails to actually be square instead of whatever aspect ratio the images themselves have.
This is what my code looks like:
<div class="gallery">
<a href="#"><img class="tile" src="#"></a>
</div>
(the a
and img
tags repeat a bunch of times in each of the gallery
divs)
And this is my CSS:
.gallery {
width: 100%;
max-width: 1400px;
min-width: 600px;
margin: 0 auto;
margin-top: 1rem;
font-size: 0px;
margin-bottom: 3rem;
}
.gallery img{
display: inline-block;
object-fit: cover;
width: 25%;
}
The only object-fit
that works is none
which does manage to contain them in the square shape but also doesn't scaled them down at all.
I don't think I can use something other than percentages, because I need the thumbnails to scale down when the gallery
div itself does.