SoFunction
Updated on 2025-04-03

Javascript drag and drop series article 1 of offsetParent attribute page 2/3


Test results:
Firefox3:"BODY"
Internet Explorer 7:"BODY"
Opera 9.51:"BODY"
Chrome 0.2:"BODY"
Safari 3:"BODY"
in conclusion:
When neither an element nor its parent element is CSS positioned, the offsetParent property of this element is taken as the root element. More specifically, the reference object for the various offset calculations of this element (offsetTop, offsetLeft, etc.) is the Body element. (In fact, whether it is standard compatibility mode or weird mode, the root element is a Body element)
Test Code 2:

[Ctrl+A Select all Note:Introducing external Js requires refreshing the page before execution]

Test results:
Firefox3:"DIV"
Internet Explorer 7:"DIV"
Opera 9.51:"DIV"
Chrome 0.2:"DIV"
Safari 3:"DIV"
in conclusion:
When the parent element of an element is CSS positioned (absolute or relative), the offsetParent property of this element is its parent element. More specifically, the reference object for the various offset calculations of this element (offsetTop, offsetLeft, etc.) is its parent element.
Test Code 3:

[Ctrl+A Select all Note:Introducing external Js requires refreshing the page before execution]
Test results:
Firefox3:"H1"
Internet Explorer 7:"H1"
Opera 9.51:"H1"
Chrome 0.2:"H1"
Safari 3:"H1"
in conclusion:
When neither an element nor its parent element is CSS positioned (absolute or relative), the value of the offsetParent property of this element is the element closest to it in the DOM structure level and has CSS positioned.
Previous page123Next pageRead the full text