Ensure two div-elements will get the same height (jquery solution)

Currently I’m working on a small web application with the requirement to bring the height of two side-by-side div elements on the same level. The content of this two elements are different and the width depends on the browser window. This means the div content floats in the elements and the height depends on the height of the inner content. I tried to find a working solution based on CSS only. At the end I want to share a jquery based solution which works well for me

  1. The following markup can be found in many web apps
  2. First I added  jquery and code to identify the div with the maximum height. After that this height will be set at the second div element as well
  3. Finally moving out the code into a separate function helps to reuse this code in other apps as well. It could als be a good idea to build a small jquery plugin




Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s