Return to Snippet

Revision: 46316
at May 17, 2011 10:49 by garciaon


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;
}
 
//Use the above function as:
$(element).center();

Initial URL

                                

Initial Description

                                

Initial Title
Criar um novo método

Initial Tags

                                

Initial Language
jQuery