javascript - How to make an image height resize accordingly to the size of the contents below it, in a fixed size container -
i understand hard one, have 10+ years working html, can't find solution doesn't involve working complicated calculations javascript.
i have fixed-size container divided in two, container has top half , bottom half. top half has image. bottom half has text. want image , text occupy available space. if text short, there more space available image. if text larger, image smaller, dynamically. i've added couple of screenshots illustrate want. in cases, occupy 100% of available vertical space of fixed-size container.
here's pure css approach
you can try using display: table-row
https://jsfiddle.net/4h37fv7o/
try , modify length of text @ bottom , see image resize.
there caveats works.
alternatively, can use flexbox albeit, using background image: