获取元素尺寸
+ 元素的占地面积
+ 占地面积: 内容区域 + padding + border
两组方式
1. offsetWidth 和 offsetHeight
+ 语法:
=> 元素.offsetWidth
=> 元素.offsetHeight
+ 得到:
=> 元素的 内容 + padding + border 区域的尺寸
+ 注意: display: none 以后表示不占页面位置,为 0
2. clientWidth 和 clientHeight
+ 语法:
=> 元素.clientWidth
=> 元素.clientHeight
+ 得到:
=> 元素 内容 + padding 区域的尺寸
+ 注意: display: none 后为 0
var div = document.querySelector('div')
console.log('offsetWidth: ', div.offsetWidth)
console.log('offsetHeight: ', div.offsetHeight)
console.log('=================')
console.log('clientWidth: ', div.clientWidth)
console.log('clientHeight: '