Skip to content

Instantly share code, notes, and snippets.

@dannevang
Created March 10, 2014 10:20
Show Gist options
  • Save dannevang/9462518 to your computer and use it in GitHub Desktop.
Save dannevang/9462518 to your computer and use it in GitHub Desktop.
jQuery Full height columns
//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