offset(偏移)系列
offset系列需要保证保证父盒子有非static定位,即absolute、relative、fixed
offset与style的区别
offset
- offset 可以得到任意样式表中的样式值
- offset 系列获得的数值是没有单位的
- offsetWidth 包含 padding+border+width
-
style
style 只能得到行内样式表中的样式值
- style.width 获得的是带有单位的字符串
- style.width 获得不包含 padding 和 border 的值
- style.width 是可读写属性,可以获取也可以赋值
- 所以,我们想要给元素更改值,则需要用 style 改变
scroll系列
scroll滚动
classlist
知名框架
本地存储
localStorage
删除
清空sessionStorage与localStorage的不同点