jQuery Mobile - Full Height content area
Posted Thu, 09 Dec 2010
I was working on integrating jQuery Mobile stuff into fingerpoken and needed a
way to make the content area of pages full-screen. By 'full screen' I mean
still showing the header and footer, but otherwise the content needs to fill
the rest.
I couldn't find an easy way to do this while googling, and even the jQuery Mobile demos didn't do it.
So here's a demo of what I came up with here: fullheight jQuery Mobile demo Javascript:
var fixgeometry = function() {
/* Some orientation changes leave the scroll position at something
* that isn't 0,0. This is annoying for user experience. */
scroll(0, 0);
/* Calculate the geometry that our content area should take */
var header = $(".header:visible");
var footer = $(".footer:visible");
var content = $(".content:visible");
var viewport_height = $(window).height();
var content_height = viewport_height - header.outerHeight() - footer.outerHeight();
/* Trim margin/border/padding height */
content_height -= (content.outerHeight() - content.height());
content.height(content_height);
}; /* fixgeometry */
$(document).ready(function() {
$(window).bind("orientationchange resize pageshow", fixgeometry);
});