您的位置:首页 > Web前端 > JavaScript

JS-----元素定位自动居中

2015-10-20 12:46 561 查看
元素定位自动居中 .html

<div class="dialoge-set">
</div>


元素定位自动居中 .js

//元素定位自动居中
jQuery.fn.center = function() {
this.css("position", "absolute");
this.css("top","50%");
this.css('left',"50%");
this.css("margin-top", -(this.innerHeight()) / 2 + "px");
this.css("margin-left", -(this.innerWidth()) / 2 + "px");
return this;
}

//弹窗其他设置
$('.dialoge-set').center();
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  定位居中