I have created a jsFiddle for this question.
a.tip {
position: relative;
}
a.tip span {
display: none;
position: absolute;
top: -5px;
left: 60px;
width: 125px;
padding: 5px;
z-index: 100;
background: #000;
color: #fff;
-moz-border-radius: 5px; /* this works only in camino/firefox */
-webkit-border-radius: 5px; /* this is just for Safari */
}
a:hover.tip {
font-size: 99%; /* this is just for IE */
}
a:hover.tip span {
display: block;
}
<center><a href="http://google.com/" class="tip">Link!<span>Hi its me!</span></a></center>
Basically I have a tooltip on my site, and it appears to the right of my link. But on the left hand side of the black box I would like a triangle attached to the box pointing to the link, is it possible to do this using only CSS? just like this but to the left
You can put both color and image as background and also set its position . In the code below replace the image in the
url
tag with one that has the triangle you want.see more here http://www.w3schools.com/cssref/pr_background-position.asp
Try this: http://ecoconsulting.co.uk/examples/css-tooltip/
It explains the problems and fixes the issues, and allows for an arrow and tooltip with a border.
Contents of the link
CSS-only tooltips using
:after
and:before
These tooltip rollovers use a custom HTML5 a tag data- attribute (data-tooltip) to populate a tooltip displaying text contained in the attribute. The arrow triangle is formed by two generated overlapping elements with only the top border visible (r-l are transparent, bottom is 0px). All tooltip text is an extension of the link and therefore clickable.
View source to get code - it's as clean as possible, and each tooltip has a separate block of css styles—use the Arrow tooltip (final) CSS for the finished styles. Don't like the colour? You know what to do. Original inspiration: Nicolas Gallagher's Pure CSS speech bubbles, and a desire to emulate Addy Osmani's JQuery tooltip in pure CSS.
CSS-only tooltip using
:before
(no arrow)CSS-only tooltip arrow with
:before
and:after
(a
tag inside span)Fault: lingering triangle when hovering over arrow's 'border'. Fault: Mozilla (Firefox): arrow border is beneath link, needs higher z-index.
:before
and:after
(span
insidea
tag)You can add it to any link by applying the tooltip class and wrapping the link text in a span. The tooltip inherits the span's
font-weight
value by default.Sadly, CSS3 (in this case fade-in-nicely) transitions on generated elements aren't supported widely enough yet (FF only but even there, I couldn't get it to work).
You can do it with CSS, by using the css triangle trick
Demo at http://jsfiddle.net/dAutM/7/
live snippet
I developed CSStooltip.com to make tooltips with triangle in CSS only.
Example :