Created
October 27, 2012 17:01
-
-
Save dei79/3965331 to your computer and use it in GitHub Desktop.
Ensure two div-elements will get the same height (jquery solution)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js" type="text/javascript"></script> | |
<script> | |
$(function() { | |
// get the max height of the two divs | |
var $maxHeight = Math.max($('#left').height(),$('#right').height()) | |
// get the lower div | |
var $lowerpanel = $('#left') | |
if ($lowerpanel.height() > $('#right').height()) | |
$lowerpanel = $('#right') | |
// set the height of the lower panel | |
$lowerpanel.height($maxHeight) | |
}) | |
</script> | |
<style> | |
#id { | |
float: left; | |
} | |
#left { | |
float: left; | |
width: 50%; | |
background-color: red; | |
} | |
#right { | |
float: left; | |
width: 50%; | |
background-color: yellow; | |
} | |
</style> | |
</head> | |
<body> | |
<div id="container"> | |
<div id="left"> | |
The left page | |
</div> | |
<div id="right"> | |
The right page | |
<br/> | |
<br/> | |
<br/> | |
with more content | |
</div> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
how do we get the higher panel instead of lower panel