So I noticed with just div display table with width 0, the h2 inside that div takes up as much width needed, however, the question is now, why when adding a parent div outside of all that with display flex, now the h2 gets a linebreak on img width.
.container {
display: flex;
flex-direction: row;
}
img {
height: 20vh;
}
.single-container {
display: table;
width: 0;
}
<div class="container">
<div class="single-container">
<img src="https://imagesvc.timeincapp.com/v3/mm/image?url=https%3A%2F%2Ftimedotcom.files.wordpress.com%2F2014%2F11%2F84146440.jpg&w=800&q=85" alt="">
<h2>I'm trying to not make this more than image width.</h2>
</div>
<div class="single-container">
<img class="img2" src="https://imagesvc.timeincapp.com/v3/mm/image?url=https%3A%2F%2Ftimedotcom.files.wordpress.com%2F2014%2F11%2F84146440.jpg&w=800&q=85" alt="">
<h2>I'm trying to not make this more than image width.</h2>
</div>
<div class="single-container">
<img src="https://imagesvc.timeincapp.com/v3/mm/image?url=https%3A%2F%2Ftimedotcom.files.wordpress.com%2F2014%2F11%2F84146440.jpg&w=800&q=85" alt="">
<h2>I'm trying to not make this more than image width.</h2>
</div>
</div>