When I was developing a color picker yesterday, I wanted to locate the ecliper in a pop-up box. So I used the position: absolute attribute. Obtains the position of the clicked element. The method for obtaining its position is to use $ (this). offset (). Left, $ (this). offset (). Top. Because absoulte is located relative to the page. So when I scroll the scroll bar in the pop-up box, it will not scroll. At that time, the solution I came up with was to use a method to obtain whether scroll is scroll up or down.
You can use $ ("Div"). Scroll (). Obtain the scrolltop value and compare it with the value of the previous scroll to determine whether to scroll up or down.
However, I later thought of a more convenient solution, that is, not to use absolute for locating. Insert the element directly to the bottom layer, and use margin-left and margin-Right to locate the element. I personally think this is the best way.