Skip to content

Instantly share code, notes, and snippets.

@textarcana
Created February 20, 2009 22:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save textarcana/67750 to your computer and use it in GitHub Desktop.
Save textarcana/67750 to your computer and use it in GitHub Desktop.
One way to ensure one column is the same height as another. Extra complex because I am using 'sliding doors' drop shadow on the columns. Appears to work in FF, IE, Opera, Chrome and Webkit but ymmv.
/**
* Equal height column hack for Favorites box
*/
var fudgeAmt = (document.all === null ? 47 : 27);
var heightToMatch = $('equalHeightColumnsHack').clientHeight - fudgeAmt;
var shadowHeight = heightToMatch + 24;
var elems = {};
elems.container = $$('#featured .content')[0];
elems.shadow = $$('#featured .content .dropShadowHack')[0];
/* Prettified the getComputedStyle wrapper a bit over what's in the repo, see http://www.quirksmode.org/dom/getstyles.html */
var shadowBgLeft = (function(){
if (elems.shadow.currentStyle) {
var sty = elems.shadow.currentStyle;
return sty.backgroundPositionX;
} else {
var sty = document.defaultView.getComputedStyle(elems.shadow, '');
return sty.backgroundPosition.split(' ')[0];
}
})();
elems.container.style.height = heightToMatch + 'px';
elems.shadow.style.height = shadowHeight + 'px';
elems.shadow.style.backgroundPosition = shadowBgLeft + ' bottom';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment