0
点赞
收藏
分享

微信扫一扫

JS - scrollWidth、clientWidth、offsetWidth 区别


一、属性说明:


  1. clientWidth = width(可见区域)+ padding - 滚动条宽度
  2. offsetWidth = width(可见区域) + padding + border(若有滚动条宽,那就包含在里面了)
  3. scrollWidth = width(自身实际长度,包括不可见区) + padding + border + margin

二、图例:

JS - scrollWidth、clientWidth、offsetWidth 区别_scrollWidth

JS - scrollWidth、clientWidth、offsetWidth 区别_offsetWidth_02

JS - scrollWidth、clientWidth、offsetWidth 区别_scrollWidth_03


举报

相关推荐

0 条评论