In jquery, jquery.offset().top/left is used to get the distance of the div from the window, and jquery.position().top/left is used to get the distance from the parent div (it must be an absolutely positioned div).
(1) First introduce jquery.offset().top / left
css:
js:
280px here= a.height/200px parentBox.padding-top/30px parentBox.margin-top/40px innerBox.margin-top/10px;
//If the parentBox here sets position : relative; innerBox sets position: absolute; and innerBox sets top: 40px;
//At this time, the value of _offsetTop is 290px = a.height/200px parentBox.margin-top/40px innerBox.margin-top/10px ineBox.top/40px;
//Because the absolute definition is based on the inner border of the upper left corner of the parent div as the reference coordinate.
//If the innerBox sets a border, add the border value
(2) jqury.position().top /left is used to get the distance between the child div and the parent div, and the child The div must be absolutely positioned
css:
html: