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;
}
让元素居中
本文介绍了如何使用jQuery实现元素的居中布局,通过简单的CSS属性设置,使得元素能够自动定位到窗口的中心位置。
3148

被折叠的 条评论
为什么被折叠?



