How to stretch the block to the width of the picture?

Good time!
There is a block with text, which can be a picture (the size of the image is unknown). The minimum block size will be 200px, the maximum is 400. You need to block has always been the minimum size, but only as long as there are no pictures. The same unit with the image needs to stretch along its width, but a maximum of 400px.
If you set max-width, the block tends to stretch the entire width at once, regardless of the presence of a picture and its size.
Maybe someone faced how to do it?
March 19th 20 at 09:09
1 answer
March 19th 20 at 09:11
Unless something like that
Thanks, as an option, Yes. But still not quite right. The picture can be less than 400px, then the unit needs to adjust accordingly, along with the text. - Vern_Larson commented on March 19th 20 at 09:14
@Vern_Larson, well, then I guess only JS, measure the width of the picture and affix it to the block with text - sabina.Willms commented on March 19th 20 at 09:17

Find more questions by tags FlexboxLayoutCSS