码迷,mamicode.com
首页 > 其他好文 > 详细

元素页面定位居中函数

时间:2015-10-31 18:36:29      阅读:102      评论:0      收藏:0      [点我收藏+]

标签:

function centerposition( obj ){
     var wWidth = document.documentElement.clientwidth;
     var wHeight = document.documentElement.clientHeight;
     var oWidth = obj.offsetWidth;
     var oHeight = obj.offsetHeight;
     obj.style.left = (wWidth - oWidth) / 2 + ‘px‘;
     obj.style.top = (wHeight - oHeight) / 2 + ‘px‘;
}

  

元素页面定位居中函数

标签:

原文地址:http://www.cnblogs.com/fuxiang-yang/p/4925799.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!