sliding element over navigation bar

notarypublic

New Member
This site is a tweaked version of one I posted earlier - I'm playing around with CSS3 and jquery. The site isn't anything close to being finished, at this point it's more of a proof of concept... but I'm getting there.

Currently, you'll see the red div that floats over the navigation bar. In the mockup I made in jsFiddle, the red div should float across the navigation menu to wherever the mouse is. On my site, as soon as you move your mouse over the navigation bar, the div springs to the right.

The reason for this is because the variable that stores the mouse location is relative to the left side of the window - this changes depending on the size of the window, making the formula I'm using work incorrectly. Obviously this variable needs to be based around the width of the container, not the width of the page.

I'm still pretty new at jquery (but learning quickly!) - I didn't realize that pageX was a variable that you could get from the DOM. Is there a similar way to grab a mouse's position in relationship to the edge of any other elements?
 

notarypublic

New Member
update: Got it to work! I used the this.offsetLeft property to find out how far the nav bar was away from the edge of the window. Now to just get the span to not interfere with the links below it..
 
Last edited:

notarypublic

New Member
The issue I'm trying to resolve before I say it's a success is that the arrows floating over the navBar are an image inside of a div. I want it to overlap the links because I'm going to style them more than they are currently, but you'll notice that when the div is lined up with the mouse, it sits on top of the links - and then you can't click on the link.

Any ideas?
 
Top