Kevin Powell - CommunityKP-C
Kevin Powell - Community8mo ago
21 replies
Solin

Fitting an image in a div, when the div doesn't have defined width/height

Hi everyone.
The issue I sometimes face is that lets say i have a grid of 2 cols 1 row. on the left side i have text content and the right side is a div with an image inside.
If I want the height of the grid to be determined by the text content on the left side, and I set the image to 100% width and height, what ends up happening is that the image expands the grid and determines the grid's height. The only way I can avoid this is by having the image as the background of the div instead. What would be the better approach if I want to use the image?
Was this page helpful?