Created
March 10, 2014 10:20
-
-
Save dannevang/9462518 to your computer and use it in GitHub Desktop.
jQuery Full height columns
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
//CALL THIS IN THE FOOTER, AFTER THE DOM HAS BEEN LOADED AND ANY OTHER DOM MANIPULATING JS HAS BEEN EXECUTED | |
function updateSidebar() { | |
var $width = document.documentElement.clientWidth, | |
$height = document.documentElement.clientHeight, | |
$main = jQuery('#main').height(); | |
$sidebar = jQuery('#sidebar').height(); | |
if($width > 755) { | |
if($main > $sidebar) { | |
jQuery('#sidebar').css({'min-height': $main}); | |
} else { | |
jQuery('#main').css({'min-height': $sidebar}); | |
} | |
} else { | |
jQuery('#sidebar').removeAttr('style'); | |
} | |
} | |
// then call it on load AND browser resize | |
$(window) | |
.load(function() { | |
updateSidebar(); | |
}) | |
.resize(function(){ | |
updateSidebar(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment