When I make an HTTP call to fetch a block of HTML from an external source, the structure of the retrieved HTML looks like this:
<div class="container">
<div class="wrapper">
<div class="image">
<img src="img_url>
</div>
<div class="text_wrapper>
<div class="text>
text...
</div>
</div>
The retrieved HTML blocks contain multiple container divs with the same structure as mentioned above, but the images may vary in size. I am attempting to display the container divs in the following manner:
https://i.sstatic.net/3X1vk.jpg
In the image above, the image part has a width of 50% and the text has a width of 50%. I want to maintain the aspect ratio, so the images have a fixed width but the height is set to auto. This causes the images to have different heights. I want the parent div (container) to adjust its height based on the height of the image it contains. I have tried various methods using pure CSS, but have not achieved the desired results. Is there a way to achieve this behavior with pure CSS, or do I need another tool like jQuery? I am displaying the HTML in my Angular 2 application, by the way.