0

I want to do something like this: PhotoView fit screen height maintain aspect ratio in CSS as shown in the first two pictures. The method i'm currently using, cover, gets silly while on mobile so that the background image covers only the above part, like this.

How can i resize the image so that it keeps this aspect ratio, but covers the whole screen, even if it means cutting some of the picture out?

Milo
  • 50
  • 4

1 Answers1

1

object-fit: cover is the right thing to use for this. Your issue seems to lie within the container's height. Try setting a min-height: 100vh; for it?

Or, if that's not the case, please provide a working test-case of your code, so we can see what's actually going on.

thykka
  • 540
  • 2
  • 12
  • Hi, this is an old post, but this was most likely the issue. If I had to replicate it today, I would probably have gone for dynamic resizing. – Milo Apr 13 '23 at 16:25