jqeury设置元素屏幕居中

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();

原文地址:https://www.cnblogs.com/weibozeng/p/3544315.html