Tooltip arrow right

2019-08-01 08:11发布

问题:

I'm trying to make this tooltip arrow point to the right towards the link.

CSS

.tooltipside
{
position: relative;
cursor: help;
display: inline-block;
outline: none;
}

.tooltipside span
{
visibility: hidden;
position: absolute; 
bottom: -22px;

z-index: 999;
width: 52px;
margin-left: -63px;
padding: 2px;
border: 1px solid #80a7ba;
background-color: white;                     
-moz-border-radius: 4px;
border-radius: 4px;  
-moz-box-shadow: 0 1px 2px rgba(0,0,0,.4), 0 1px 0 rgba(255,255,255,.5) inset;
-webkit-box-shadow: 0 1px 2px rgba(0,0,0,.4), 0 1px 0 rgba(255,255,255,.5) inset;
box-shadow: 0 1px 2px rgba(0,0,0,.4), 0 1px 0 rgba(255,255,255,.5) inset;  
text-shadow: 0 1px 0 rgba(255,255,255,.4); 
}

.tooltipside:hover
{
border: 0; /* IE6 fix */
}

.tooltipside:hover span
{
visibility: visible;
}

.tooltipside span:before,
.tooltipside span:after
{
content: "";
position: absolute;
z-index: 1000;
bottom: -7px;
left: 50%;
margin-left: -8px;  
border-top: 8px solid #80a7ba;
border-left: 8px solid transparent;
border-right: 8px solid transparent;        
border-bottom: 0;  
}

.tooltipside span:before
{
border-top-color: #ccc;
bottom: -8px;
}

​ The html is

 <a href='#' class='tooltipside'><span>
 <img src='http://cdn2.iconfinder.com/data/icons/32pxmania/misc_57.png' 
  border='0' width='52' height='52'></span>LINK</a> TEST TEST TEST</b>​

It currently points down in the center of the tooltip I need it to point right towards the link. How would I do this?

Thanks

回答1:

Is this what you are after? http://jsfiddle.net/kX5kH/

I used the positioning to move the arrow, then swapped around the transparent broders to make the arrow point the right way.

NOTE: I added a parent <div> and positioned it absolutely, because it was otherwise hugging the edge and you couldn't see the tool tip.

Also there's no starting <b> tag.

One last note, I noticed you had a IE6 fix, which is intriguing because none of this will work in IE6. Box shadows, before/after selectors, and transparent borders will not appear correctly. But honestly I wouldn't be concerned about IE6 =P

Hope this helps.



标签: html css tooltip