Skip to content

Instantly share code, notes, and snippets.

@ace4gi
Created July 15, 2014 01:05
Show Gist options
  • Select an option

  • Save ace4gi/38f338ba5b9c4d96721f to your computer and use it in GitHub Desktop.

Select an option

Save ace4gi/38f338ba5b9c4d96721f to your computer and use it in GitHub Desktop.
mobile - minHeight 100% layout
$(document).ready(function(){
if( $("body").hasClass("layout-static") ){
return;
}
var $wrap = $("#contwrap");
var $header = $wrap.find(">header:first");
var $footer = $wrap.find(">footer:first");
var $container = $("#container");
$(window).on("resize", function(){
var winHeight = $(window).height();
var headerHeight = $header.length ? $header.innerHeight() : 0;
var footerHeight = $footer.length ? $footer.innerHeight() : 0;
var containerHeight = $container.length ? $container.innerHeight() : 0;
var contwrapHeight = $wrap.innerHeight();
$container.css("minHeight", "");
if(contwrapHeight <= winHeight){
$container.css("minHeight", winHeight - headerHeight - footerHeight );
}
})
.trigger("resize");
$(window).load(function(){
$(window).trigger("resize");
});
window.onorientationchange = function() {
if(window.orientation == 90 || window.orientation == -90){
$container.css("minHeight", "0");
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment