首页 > 其他 > 详细

jqeury设置元素屏幕居中

时间:2014-02-11 19:30:53      阅读:353      评论:0      收藏:0      [点我收藏+]

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

jqeury设置元素屏幕居中

原文:http://www.cnblogs.com/weibozeng/p/3544315.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!