Skip to content

Instantly share code, notes, and snippets.

@amiel
Forked from nathancarnes/gist:396692
Created May 10, 2010 23:36
Show Gist options
  • Save amiel/396696 to your computer and use it in GitHub Desktop.
Save amiel/396696 to your computer and use it in GitHub Desktop.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>Equal Heights Test</title>
<style type="text/css" media="screen">
#container{ width: 960px; margin: 20px auto; }
#foo, #bar{ float: left; margin: 10px; width: 456px; background: #eee; border: 1px solid #333; }
</style>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js" type="text/javascript"></script>
<script src="matchHeights.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
$('#foo, #bar').matchHeights();
});
</script>
</head>
<body>
<div id="container" class="we arnt going to use this">
<div id="foo">
<p>bar</p>
</div>
<div id="bar">
<ul>
<li>A</li>
<li>Taller</li>
<li>Div</li>
</ul>
</div>
</div>
</body>
</html>
$.fn.matchHeights = function(px) {
var currentTallest = 0;
$(this).each(function(i){
if ($(this).height() > currentTallest) currentTallest = $(this).height();
});
if ($.browser.msie && $.browser.version == 6.0) { $(this).children().css({'height': currentTallest}); }
$(this).css({'min-height': currentTallest});
return this;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment