I have a viewport that takes up about 75% of the screen and I fit single images of varying aspect ratios into it using the object-fit: contain
css. Above the image I have text labels for the file name & type. I want to keep these aligned to start at the left most edge of the image and end at the right most edge. I could do this easily before by aligning them to the <img>
tag.
One side effect of using object-fit: contain
is that the <img>
element is bigger than the viewable picture, so when I try to align text to the <img>
it can appear that the text is floating off of the image.
How can I align the text to the viewable image, when the img
tag is expanded to fit the whole viewport but the actual picture is autoscaled inside the img
tag using object-fit: contain
?