Как можно разместить DIV по центру экрана на jQuery?

Я бы сделал отдельную функцию:

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;
}

Использовать её просто и приятно:

$(element).center();
По вопросам рекламы ammmcru@yandex.ru
Adblock
detector