Use offset function to position block elements
This commit is contained in:
parent
29bb5d27e4
commit
30498fd6f8
|
@ -297,7 +297,10 @@ function object(o) {
|
||||||
* Fills height of window. (more precise than height: 100%;)
|
* Fills height of window. (more precise than height: 100%;)
|
||||||
*/
|
*/
|
||||||
function fillHeight(selector) {
|
function fillHeight(selector) {
|
||||||
var height = parseFloat($(window).height())-parseFloat(selector.css('top'));
|
if (selector.length == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var height = parseFloat($(window).height())-selector.offset().top;
|
||||||
selector.css('height', height + 'px');
|
selector.css('height', height + 'px');
|
||||||
if(selector.outerHeight() > selector.height())
|
if(selector.outerHeight() > selector.height())
|
||||||
selector.css('height', height-(selector.outerHeight()-selector.height()) + 'px');
|
selector.css('height', height-(selector.outerHeight()-selector.height()) + 'px');
|
||||||
|
@ -307,8 +310,11 @@ function fillHeight(selector) {
|
||||||
* Fills height and width of window. (more precise than height: 100%; or width: 100%;)
|
* Fills height and width of window. (more precise than height: 100%; or width: 100%;)
|
||||||
*/
|
*/
|
||||||
function fillWindow(selector) {
|
function fillWindow(selector) {
|
||||||
|
if (selector.length == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
fillHeight(selector);
|
fillHeight(selector);
|
||||||
var width = parseFloat($(window).width())-parseFloat(selector.css('left'));
|
var width = parseFloat($(window).width())-selector.offset().left;
|
||||||
selector.css('width', width + 'px');
|
selector.css('width', width + 'px');
|
||||||
if(selector.outerWidth() > selector.width())
|
if(selector.outerWidth() > selector.width())
|
||||||
selector.css('width', width-(selector.outerWidth()-selector.width()) + 'px');
|
selector.css('width', width-(selector.outerWidth()-selector.width()) + 'px');
|
||||||
|
|
Loading…
Reference in New Issue