Make Two DIVs Have Same Height


#1

I have two divs sitting side by side. One of the divs contains an image and the other will contain text. I would like the height of the two divs to be equal whether the user enters text into one of the divs or not.

I am trying to use javascritp to force the two divs to have equal height but it's not working. Please see my code pen https://codepen.io/liagapi/pen/MBwZPG


#2

You don’t need js for this as you can use flexbox for modern browsers or display:cell if you need older browser support

I suggest using flexbox and ditch your js :slight_smile:


#3

Hi PaulOB, will my image height increase or decrease when the browser size changes using flexbox? I was trying to use javascript to set the height of the image wrapper dynamically to give it a value which will then affect the height of the image.


#4

Here's an old codepen of mine from a similar question in the forums.