jquery 元素居中间
$(document).ready(function() {
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;
}
$("#id").center();
});
posted on 2011-02-20 14:05 GeorgeWang 阅读(301) 评论(0) 编辑 收藏 举报