I'm attempting to implement a crosshair-style cursor effect on a div that houses a D3 Datamap. I've managed to achieve this using jQuery, but the crosshairs appear to extend beyond the boundaries of their parent div on the bottom and right sides, while staying within those boundaries on the top and left.
To illustrate, I have put together this fiddle.
Despite my efforts to adjust the position
property of the crosshair div, I haven't been able to resolve this issue.
Interestingly, when I set the position
to absolute
on my website, it does confine the crosshairs correctly within the container, but there is an offset in the center point from the actual cursor coordinates (e.pageX, e.pageY
). Unfortunately, these results cannot be reproduced in the fiddle since changing between
fixed, static, relative, absolute
doesn't seem to make a difference.
One workaround I discovered was to assign fixed values for the width
and height
of both the container and the crosshairs. However, this poses an issue as I require the container to be responsive.