Return to Snippet

Revision: 36511
at November 22, 2010 15:28 by wesleymacente


Initial Code
jQuery.fn.center = function () {
    this.css("position","absolute");
    this.css("top", ( $(window).height() - this.height() ) / 2+$(window).scrollTop() + "px");
    this.css("left", ( $(window).width() - this.width() ) / 2+$(window).scrollLeft() + "px");
    return this;
}


$(element).center();

Initial URL


Initial Description


Initial Title
CENTER DIV WITH JQUERY

Initial Tags
jquery, center

Initial Language
jQuery