Wednesday, July 27, 2011

How to center a div by 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();

http://stackoverflow.com/questions/210717/using-jquery-to-center-a-div-on-the-screen

Model Metadata and Validation Localization using Conventions

http://haacked.com/archive/2011/07/14/model-metadata-and-validation-localization-using-conventions.aspx