N
N
nomta2019-03-29 13:27:04
css
nomta, 2019-03-29 13:27:04

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

Good time!
There is a block with text, which can contain a picture (the dimensions of the picture are not known in advance). The minimum block size is 200px, the maximum is 400. It is necessary that the block always be the minimum size, but only as long as there is no image in it. The same block with an image should stretch across its width, but up to a maximum of 400px.
If I set max-width, the block tends to stretch to the full width at once, regardless of the presence of the image and its size.
Maybe someone came across how to do this?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Valentin, 2019-03-29
@romanko_vn

Is it something like this
https://jsfiddle.net/sqept5bo/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question