Click here to Skip to main content
15,917,473 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

I have a CSS tooltip :
CSS
* {
font-family:Verdana, Arial, Helvetica, sans-serif; font-size:11px;
 }
a {text-decoration:none;}
a:hover {background:#ffffff; text-decoration:none;} /*BG color is a must for IE6*/
a.tooltp span {display:none; padding:3px 2px; margin-left:0px; width:130px;}
a.tooltp:hover span
{display:inline;
position:absolute;
top:10px;
-moz-box-shadow: 0px 0px 8px 4px #666;
    -webkit-box-shadow: 0px 0px 8px 4px #666;
    box-shadow: 0px 0px 8px 4px #666;
 border:2px solid white; background:#000; color:white;}


I use it this way:

HTML
<div class='container'>
<a href='#' class='tooltp'> <div class="box"></div><span>This is the tooltip text</span>
</a></div>


It works perfect in Chrome, but in Firefox, the tooltip is displayed on the right-end of the container div, instead of being displayed right to box div. Can anyone tell me how to fix it?
Posted
Updated 24-Jul-12 4:01am
v4
Comments
Shelby Robertson 24-Jul-12 9:56am    
It seems like you are missing some stuff from the html, what you have listed doesn't really do anything
FahdSanaullah 24-Jul-12 9:58am    
you're right...

1 solution

Absolutely positioning the span with a 'top' position of 10px means the 'tooltip' will always appear 10px from the top of the page. You can try something like this:

CSS
a.tooltp:hover span
{display:inline;
position:relative;
left:50px;
-moz-box-shadow: 0px 0px 8px 4px #666;
    -webkit-box-shadow: 0px 0px 8px 4px #666;
    box-shadow: 0px 0px 8px 4px #666;
 border:2px solid white; background:#000; color:white;}


Where the positioning is relative to the "box" div and sets the left of the tool tip 50px from the left of the box div. You may want to consider using javascript to exactly how what the value should be for that, it will depend on how wide the box div is.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900