HTML DOM 元素 offsetParent 屬性
描述
offsetParent
屬性返回最近的、定位不為 static 的祖先元素。
如果元素不可見 (display="none"),則 offsetParent
屬性返回 null
。
教程
offsetParent
所有塊級元素都報告相對於 offset 父級的偏移量
- offsetTop
- offsetLeft
- offsetWidth
- offsetHeight
offset 父級是最近的、position 屬性不為 static 的祖先元素。
如果沒有 offset parent 存在,則 offset parent 是文件的 body。
另請參閱
語法
element.offsetParent
返回值
型別 | 描述 |
節點 | 最近的已定位祖先元素。 |
瀏覽器支援
element.offsetParent
在所有瀏覽器中都受支援
Chrome | Edge | Firefox | Safari | Opera | IE |
是 | 是 | 是 | 是 | 是 | 是 |