0

I have four divs side by side. I'd like the height of them to be the same, and stay the same if one of them resizes. means, if one grows because text is placed into it, the other one should grow to match the height.

Here is my :Fiddle

Please resize the width of answer

Thank you.

8
  • Well, there are 2 side-by-side in 2 rows, so do you mean they all 4 should have same height? ... Or all 4 should be on the same row? Commented Aug 18, 2017 at 9:17
  • @LGSon, In Smaller Screen that's not a problem. But larger screen it split into 2 lines. so, that time the problem happens. Commented Aug 18, 2017 at 9:20
  • Okay, to make elements on different rows the same height you need a script...elements on the same row can keep same height using CSS, which is normally more important, so they all vertical align properly Commented Aug 18, 2017 at 9:20
  • @LGSon All 4 they have same height. Please help me to do this. I am not familiar with scripts. Commented Aug 18, 2017 at 9:21
  • I updated your tags to include script, to attract users with more experience when it comes to script based solutions Commented Aug 18, 2017 at 9:26

2 Answers 2

1

here is your solution you should use display:flex

jsfiddle.net/94uvouzw/7/ 
Sign up to request clarification or add additional context in comments.

Comments

1
$(document).ready(function(){ var height; var maxHeight = 0; $(".test").each(function(){ height = $(this).height(); if(height > maxHeight) { maxHeight = height; } }); $(".test").css("height",maxHeight); }); 

By using jQuery

Demo Fiddle

1 Comment

You can always add JSFiddle to your jquery answer to make it more clear and acceptable.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.