Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make an equal height function resizeable on window resize

We created a very basic equal height function a while back that works great. However, we've been tasked with making the column heights resize as the window is resized. It's being implemneted into a responsive, fluid design. But the powers that be don't understand that the typical responsive use case isn't dragging your browser all over the place to accept specific break points.

Anyhow, got the markup and js setup in jsfiddle here. http://jsfiddle.net/J6uaH/3/

Just can't quite wrap my brain around adding the window resize element to the heights. Any help that anyone can provide will be hugely appreciated and would give whoever super hero bonus points, if there was such a thing!

like image 339
Ryan Palmer Avatar asked Dec 04 '22 01:12

Ryan Palmer


1 Answers

why not just add an event listener to the resize event of the window that recalculates the height of the elements?

however because you already set a fixed height to the elements, you need to reset the height of both elements to get the new maximum size.

try adding:

$(window).resize(function(){
    $('.group .module').css('height','auto');
    $('.group .module').equalHeight();
});

work in firefox. what this basicly does on every resize of the window:

  1. reset the height of the elements, meaning the browser will calculate it based on its content
  2. execute you function again to make both elements of equal height
like image 187
room13 Avatar answered Jan 04 '23 21:01

room13