JS-----元素定位自动居中
2015-10-20 12:46
561 查看
元素定位自动居中 .html
元素定位自动居中 .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();
<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();
相关文章推荐
- js模块化历程
- 常用js正则表达式
- jsp中select的onchange事件用法实例
- JSP EL表达式忽略方法
- JSP中param标签用法实例分析
- JSP实现的简单分页示例
- 【jstl&el】jstl和EL的区别和使用
- js 模块化历程
- js 模块化历程
- 百度分享js代码
- JSON格式字符串解析方法
- js调试工具查看dom元素上绑定的事件列表
- Extjs之DateField控件的鼠标点击选取事件监控
- js 获取元素内部文本
- js刷新验证码(.net)
- 说说JSON和JSONP,也许你会豁然开朗
- javascript事件有哪些?javascript的监听事件
- js调试系列
- C++、Java、JavaScript中的正则表达式
- Placeholdem文本域占位符符号标识JavaScript插件