JavaScript 极简教程 ES6 ES7

15.width,height

2020-03-12  本文已影响0人  半生_温暖纯良_Junzer

1.width,height

1.1获取窗口的高度与宽度(不包含工具条与滚动条)

var w=window.innerWidth;
var h=window.innerHeight;

1.2正文全文

// 正文全文宽
document.body.scrollWidth
// 正文全文高
document.body.scrollHeight

1.3可见区域(包含边线的宽)

相对于offsetParent 一直向上追溯到有定位的父级元素!

offsetLeft offsetTop
// 可见区域宽(包含边线的宽)
document.body.offsetWidth
// 可见区域高(包含边线的高)
document.body.offsetHeight

1.4可见区域(不包含边线的宽)

document.body.clientWidth
document.body.clientHeight

1.5被卷进去宽度,高度

document.body.scrollLeft
document.body.scrollTop

宽高

宽高
上一篇 下一篇

猜你喜欢

热点阅读