元素页面定位居中函数

时间:2015-10-31 18:33:34   收藏:0   阅读:322
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
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!