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 HTMLElement.offsetTop
-Eigenschaft (nur lesbar) gibt die Entfernung von der äußeren Grenze des aktuellen Elements (einschließlich seines Randes) bis zur oberen Innenkante des offsetParent
zurück, dem nächstgelegenen positionierten Vorfahrenelement.
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 |
Browser-Kompatibilität
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
offsetTop |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.