JSFiddle (You can edit the dimensions in the image source to experiment with its size.)
I have a simple layout: a container with some text on the left and an image on the right side. Currently, the container will take the height of the image because it is bigger than the text.
What I am trying - and failing - to achieve is using object-fit: cover;
and somehow getting the image to scale with the text. What I mean by that is that the image should take up half of the width of the screen, for which I set its width to 50 percent, but always take up the same height as the text to its left. If it is larger than the text, it should be clipped. I can do that by explicitly setting a height, but I do not know the height of the text, since it is dynamic.
I know that what I want to do is possible since I have seen it in action, for example here. The preview for a blog post on this site does the same thing. If I edit the HTML and change the image, that does not affect the height of the preview. I just do not understand how to replicate this effect.