元素页面定位居中函数

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';
}

  

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