Skip to content

Instantly share code, notes, and snippets.

@yyoshiki41
Created March 14, 2014 15:17
Show Gist options
  • Save yyoshiki41/9549772 to your computer and use it in GitHub Desktop.
Save yyoshiki41/9549772 to your computer and use it in GitHub Desktop.
Set min_height
// #contents { min-height: }
function getBrowserHeight() {
if ( window.innerHeight ) {
return window.innerHeight;
}
else if ( document.documentElement && document.documentElement.clientHeight != 0 ) {
return document.documentElement.clientHeight;
}
else if ( document.body ) {
return document.body.clientHeight;
}
return 0;
}
var header = document.getElementsByTagName('header'),
footer = document.getElementsByTagName('footer'),
contents = document.getElementById('centents'),
height_header = header[0].clientHeight,
height_footer = footer[0].clientHeight,
height_contents = getBrowserHeight() - height_header - height_footer;
contents.style.minHeight = height_contents+="px";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment