I'm trying to make it so that the height is restricted to the height of the device the image is viewed on so that you can view the entire image without having to scroll down.
To accomplish this I've used:
.specific-image {
display: block;
max-height: 92vh;
max-width: 1240px;
}
So if the image is 500x1000 px, it'll take 92vh height and if it's 1000x500, it'll have width of 1240px and height (most probably) less than 92vh.
The problem with that is that if I resize the height of the browser the image scales down, however, if I scale the width, my browser will cut part of the image and I'll have to scroll horizontally to see the full image.
Not sure how to get the best of both worlds.
https://codepen.io/BozhidarSK/pen/NBKyyW
.specific-image-flex-container {
display: flex;
}
.specific-image-column {
flex: 4;
}
.specific-image-container-element {
text-align: center;
position: relative;
display: inline-block;
width: 100%;
}
.specific-image {
display: block;
max-height: 92vh;
max-width: 1240px;
}
.stickySpecificContainer {
position: relative;
z-index: 2;
display: inline-block;
}
<div class="specific-image-flex-container">
<div class="specific-image-column">
<div class='specific-image-container-element'>
<div class="stickySpecificContainer">
<img class='specific-image' src='https://i.redd.it/1v3x2pxkjy611.png' alt='Random image' />
</div>
</div>
</div>
</div>