获取元素宽高总结
获取显示器屏幕的宽高
window.screen.height //返回显示器屏幕的高度。
window.screen.width //返回显示器屏幕的宽度。
获取显示器屏幕的可用宽高
screen.availHeight // 返回可用显示屏幕的高度 (除 Windows 任务栏之外)。
screen.availWidth//返回可用显示屏幕的宽度 (除 Windows 任务栏之外)。
获取页面实际宽高:
document.documentElement.scrollWidth || document.body.scrollWidth;
document.documentElement.scrollHeight || document.body.scrollHeight;
获取页面可视区域宽高:
document.documentElement.clientWidth || document.body.clientWidth;
document.documentElement.clientHeight || document.body.clientHeight;
获取滚动条距离左边/上边的距离:
document.documentElement.scrollLeft || document.body.scrollLeft;
document.documentElement.scrollTop || document.body.scrollTop;