/    Sign up×
Community /Pin to ProfileBookmark

div at mouse position

I am trying to figure out how to make a div appear at a mouse position. I don’t want to make a set width or length since the contents inside it will vary and don’t want to cut it off or have to big of a div. Basically I am looking to do something like you see in these forums when you mouse over a topic. Being able to go above the mouse if it is at the bottom of the screen is not a big concern. If I had any code to post I would but unfortunately I am drawing a complete blank at how to do this (with css, javascript). I have tried searching google but it seems like people have asked this but never really got an answer.

to post a comment
CSS

1 Comments(s)

Copy linkTweet thisAlerts:
@arpan10Nov 12.2008 — jonthegamer,

basically what you need is to get the coordinates of the mouse. Once you have that, you can position the div there. Here is a link that explains how to get the mouse coordinates:

http://www.codelifter.com/main/javascript/capturemouseposition1.html

hope this helps...

Arpan D
×

Success!

Help @jonthegamer spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...