js 元素的各种位置尺寸宽高

元素.offsetLeft[Top]:只读 属性 当前元素到定位父级的距离(偏移值)

到当前元素的offsetParent的距离

如果没有定位父级

   offsetParent -> body

   offsetLeft -> html

如果有定位父级

    ie7:如果自己没有定位,那么offsetLeft[Top]是到body的距离

            如果自己有定位,那么就是到定位父级的距离

    其他:到定位父级的距离

style.width:样式宽

clientWidth:(样式宽+padding)可视区宽

offsetWidth:(样式宽+padding+边框)占位宽

猜你喜欢

转载自blog.csdn.net/qq_35187942/article/details/85852783
今日推荐