Return to Snippet

Revision: 26022
at April 16, 2010 06:55 by alejandrosuch


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 element on screen

Initial Tags
center

Initial Language
jQuery