<div class="p-4">
<div class="grid gap-4 sm:gap-8 grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 xl:grid-cols-6">
<img src="https://m.media-amazon.com/images/I/41bffUhJ4xL._SL500_.jpg" />
<img src="https://m.media-amazon.com/images/I/41bffUhJ4xL._SL500_.jpg" />
<img src="https://m.media-amazon.com/images/I/41bffUhJ4xL._SL500_.jpg" />
<img src="https://m.media-amazon.com/images/I/41bffUhJ4xL._SL500_.jpg" />
<img src="https://images.unsplash.com/photo-1612476464716-431a2751e006" />
</div>
</div>
If I have a grid-like this, how can I force the images to have a 1:1 aspect ratio? Yes, I can use object-cover, but then I would need to set a fixed width/height. Is there a way to do this while still keeping the dynamic width?