JavaScript: mouse coordinates
I have two div boxes: one that is large is the parent to the other that is small. With propeties offsetX and offsetY, I find out the coorinates of the mouse pointer. I only need coordinates relativ开发者_如何学Ce to the large box, but when the mouse pointer is over the small box, coordinates are figured out relative to this small box. How do I get coordinates relative to the large box even though the mouse pointer is over the small box?
I assume that is because the small box is absolutely or relatively positioned (position: absolute
position: relative
). Can you change that so that only the parent is absolutely positioned?
Otherwise, the JS Frameworks should offer everything you need to convert relative into absolute positions, and correlate them to the mouse cursor.
精彩评论