各种浏览器高度

各种浏览器高度:

obj.clientHeight; //本身的高度+padding
obj.offsetHeight; //包含边框的高+padding+border

document.body.clientHeight //body的高
document.documentElement.clientHeight  //可视区域即一个屏幕的高:documentElement=html
document.documentElement.scrollHeight //出现滚动条的高
document.documentElement.scrollTop //已经滚动了多高
//document.body.scrollTop //google兼容写法


obj.offsetLeft:当前元素到父级的偏移距离;
如果有定位父级
ie7下:如果自身没有定位,默认是到body;
其它:到定位父级的距离;

如果没有定位父级
offsetParent ->body
offsetLeft -> html


obj.style.样式宽=content
obj.clientWidth:可视宽=content+padding
obj.offsetWidth:占位宽=content+padding+border
原文地址:https://www.cnblogs.com/lisa2544/p/5512412.html