I have this html
.picture-image {
height: 100vh;
overflow: hidden;
position: relative;
}
.picture-image > img {
position: absolute;
top: 0;
right: 0;
left: 0;
bottom: 0;
width: 100%;
height: 100%;
object-fit: contain;
}
<div class="picture">
<div class="picture-image">
<img alt="" src="">
</div>
</div>
This displays a div with height and width matching the screen, and the image is centered in it, adapting to the div size. It is pretty nice on desktop screens but not in mobile where we usually have a portrait orientation, and this solution causes to show a lot of white space above and below the image.
What can I do to reduce the height (not the width) of the div to match the image height?
If you think there's a better way to display a single image on both desktop and mobile I am open to suggestions.