How to calculate the distance between two div

clipboard.png


you can use getBoundingClientRect () to get the vertical distance from the element to the window, and then calculate the difference between the two vertical distances


Emergency title 1 is the list of ulli if this is a list, you can directly get the height of the ul
or the offsettop of the first offsettop and the second div-the first distance comes out

Menu