HTMLElement: offsetTop-Eigenschaft
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
Die offsetTop
schreibgeschützte Eigenschaft des HTMLElement
-Interfaces gibt die Entfernung vom äußeren Rand des aktuellen Elements (einschließlich seines Randes) bis zum oberen Innenabstand des offsetParent
, des nächstgelegenen positionierten Vorfahren-Elements, zurück.
Wert
Eine Zahl.
Beispiele
js
const d = document.getElementById("div1");
const topPos = d.offsetTop;
if (topPos > 10) {
// object offset is more
// than 10 pixels from its parent
}
Spezifikationen
Specification |
---|
CSSOM View Module # dom-htmlelement-offsettop |