d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Absolute Div Positioning
Add Reply New Topic New Poll
Member
Posts: 1,358
Joined: Dec 30 2012
Gold: 0.10
Aug 22 2014 02:40pm
What im trying to do is have an absolute div show above some text when the text is hovered over.

Currently, I have the div showing on hover but it's positioning its self under the text and not over it like i'd like.

Also i would like to have the divs center point to be aligned / move with the cursor's X coord when it hovers over the text from left to right.

I'm not sure if the positioning of the div relative to the mouse cursor's X coord is something that can be done with pure CSS or if javascript / jquery needs to be used.

This is what I have so far: http://jsfiddle.net/t5r5LL50/
Retired Moderator
Posts: 21,073
Joined: Apr 7 2008
Gold: 5,135.90
Trader: Trusted
Aug 23 2014 01:30am
Can you use z scores for this?
Member
Posts: 1,358
Joined: Dec 30 2012
Gold: 0.10
Aug 23 2014 08:00am
Quote (Kagura @ Aug 22 2014 11:30pm)
Can you use z scores for this?


You mean z-index?

Im not that familiar with CSS / web development languages but afaik z-index is for layering or stacking. Could be wrong though.

Retired Moderator
Posts: 15,410
Joined: Jun 2 2005
Gold: 9,504.66
Trader: Trusted
Aug 23 2014 11:18pm
to stack the text on hover you could use the following:

Code
<style>
.t span {display: none;}
.t:hover span {display:block;position:absolute;}
</style>
<div class="t"><span>derder der der</span>text text text text text text text</div>


to achieve a tooltip that follows the cursor, it would require js.

edit#2: moving one with js: http://jsfiddle.net/egr83n3a/

edit: on a side note, jquery is a library made with js and the desired effect could be achieved with some simple js and not the bulk of the entire jquery library.

also, you're correct z-index is simply the z positioning of elements on a page.

This post was edited by Markro on Aug 23 2014 11:45pm
Member
Posts: 1,358
Joined: Dec 30 2012
Gold: 0.10
Aug 24 2014 05:04pm
Quote (Markro @ Aug 23 2014 09:18pm)
to stack the text on hover you could use the following:

Code
<style>
.t span {display: none;}
.t:hover span {display:block;position:absolute;}
</style>
<div class="t"><span>derder der der</span>text text text text text text text</div>


to achieve a tooltip that follows the cursor, it would require js.

edit#2: moving one with js: http://jsfiddle.net/egr83n3a/

edit: on a side note, jquery is a library made with js and the desired effect could be achieved with some simple js and not the bulk of the entire jquery library.

also, you're correct z-index is simply the z positioning of elements on a page.


awesome, that did the trick. thanks :)
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll