I have a webpage laid out as follows...
|----------------------|
| |----------| |
| | Logo div | |
| |----------| |
| |
| |----------| |
| | | |
| | Content | |
| | | |
| |----------| |
|----------------------|
Currently I'm attempting to center my div
(Content
) using the following function:
jQuery.fn.center = function () {
this.css("position","absolute");
this.css("top", (($(window).height() - this.outerHeight()) / 2) +
$(window).scrollTop() + "px");
this.css("left", (($(window).width() - this.outerWidth()) / 2) +
$(window).scrollLeft() + "px");
return this;
}
which I obtained from another SO question: Using jQuery to center a DIV on the screen
This function works fine if my resolution is large enough, however on smaller screens it causes the div
I'm centering to "come up" and share space with a div
containing a Logo above it. So what I'd like to achieve with jQuery is to center it vertically in-between the logo div
#logo
and the "end" of the page without floating on top of the logo div
.
How would I do this using jQuery?