offsetParent property
Element?
get
offsetParent
inherited
The HTMLElement.offsetParent read-only property returns a
reference to the element which is the closest (nearest in the containment
hierarchy)
positioned ancestor element.
A positioned ancestor is either:
- an element with a non-static position, or
td,th,tablein case the element itself is static positioned.
If there is no positioned ancestor element, the body is returned.
Note:
offsetParentreturnsnullin the following situations:
- The element or any ancestor has the
displayproperty set tonone.- The element has the
positionproperty set tofixed(Firefox returns<body>).- The element is
<body>or<html>.
offsetParent is useful because
HTMLElement.offsetTop and
HTMLElement.offsetLeft are relative to its padding edge.
Implementation
external Element? get offsetParent;