Sexy Tooltip using CSS3 (no images)

CSS is Awesome, but “CSS3” is Awesomely Awesome.

With CSS3 we can make our pages even more beautiful without using additional images and extra markup.

In this post I have tried to make tooltips using CSS3. This is just a sample implementation for tooltip, you can have even better variants.

Here, this example is semantic HTML. No empty elements, no unnecessary extra elements, no JavaScript, no images.

The inspiration for these tooltips is from the excellent attempt from “Nicolas Gallagher” in Pure CSS speech bubbles.

Lets first head on to the demo for its actual effect.

Tooltip Demo

Tooltip using CSS3

Tooltip using CSS3

Interested ??? Lets head on to its code

HTML Markup

The HTML used here is very simple, just add class”tooltip” and in title put tooltip text.

<a class="tooltip" title="This is first tooltip" href="#">Link</a>

CSS Code

The CSS for this effect utilizes :before and :after to show tooltip. Moreover box-shadow, gradient, border-radius properties of CSS3 are used to add some glare. Here is the code.

a.tooltip:after{
	font:12px/1.4 Arial,Georgia,sans-serif;
	content: attr(title);
	display:none;
	position:absolute;
	padding:5px 10px;
	top:0px;
	margin:1em 0 3em;
	color:#fff;
	background:#075698;
	left:-20px;
 
	-moz-border-radius:4px;
	-webkit-border-radius:4px;
	border-radius:4px;
 
	background:-webkit-gradient(linear, left top, left bottom, from(#075698), to(#2e88c4));
	background:-moz-linear-gradient(top, #075698, #2e88c4);
	background:-o-linear-gradient(top, #075698, #2e88c4);
	background:linear-gradient(top, #075698, #2e88c4);
 
	-moz-box-shadow: 0px 0px 4px #000; /* FF3.5+ */
	-webkit-box-shadow: 0px 0px 4px #000; /* Saf3.0+, Chrome */
	box-shadow: 0px 0px 4px #000; /* Opera 10.5, IE 9.0 */
	filter:  progid:DXImageTransform.Microsoft.dropshadow(OffX=0px, OffY=0px, Color='#000'); /* IE6,IE7 */
	-ms-filter: "progid:DXImageTransform.Microsoft.dropshadow(OffX=0px, OffY=0px, Color='#000')"; /* IE8 */
}
 
/* creates triangle */
a.tooltip:before{
	z-index:13;
	position:absolute;
	content:"\00a0";
	display:none;
	width:0;
	height:0;
	border-style:solid;
 
	top:-3px;
	left:0px;
	border-width:15px 7px 15px 7px;
	border-color:transparent transparent #075698;
}
 
a.tooltip:hover::before{
	display:block;
}
 
a.tooltip:hover{
	z-index:10;
	position:relative;
}
 
a.tooltip:hover::after{
	width:200px;
	display:block;
	margin:25px 0 0 10px;
}

Hope you'll like it.

0saves
If you enjoyed this post, please consider leaving a comment or subscribing to the RSS feed to have future articles delivered to your feed reader.

Other Posts which you may like:

22 responses to “Sexy Tooltip using CSS3 (no images)”

  1. Ahmed Bolica

    Nive article nitin

  2. Rod

    very nice indeed. but how to prevent the “normal” tooltip from appearing ?

  3. Raghib suleman

    thanks nitin very nice work…

  4. None

    Nice, but if the link is after an automatic line break, the tooltip is displayed where the link would be if there wasn’t a break.
    Any way to fix this, besides adding a ?

  5. Saumya

    This is not support on Image Hover

  6. Tem

    We can say whatever we want, but in a way IE6 was and is a very modern, albeit annoying, browser. A lot of things that Firefox, Safari and Opera didn’t get many years later IE6 already supported through filter/ms-filter.

  7. Всплывающая подсказка tooltip на CSS3 | div верстка,уроки верстки,html верстка

    [...] Источник [...]

  8. Beginner’s Guide to CSS3

    [...] Tooltip using CSS3 (no image), [...]

  9. Beginner’s Guide to CSS3 | Ruturaj Pradeep Kohok | Your Web Advisor

    [...] Tooltip using CSS3 (no image), [...]

  10. Beginner’s Guide to CSS3 « Web Design News

    [...] Tooltip using CSS3 (no image), [...]

  11. Beginner’s Guide to CSS3 - Tips for Designers, Bloggers and Tech Users -

    [...] Tooltip using CSS3 (no image), [...]

  12. Beginner’s Guide to CSS3 | Emre Saraçoğlu's Official Blog

    [...] Tooltip using CSS3 (no image), [...]

  13. Beginner’s Guide to CSS3 « GFXForum.co

    [...] Tooltip using CSS3 (no image), [...]

  14. Beginner’s Guide to CSS3 « DownGraf – Design weblog for designers

    [...] Tooltip using CSS3 (no image), [...]

  15. Beginner’s Guide To CSS3 | How It's Easy (HIE) Computing community

    [...] Tooltip using CSS3 (no image), [...]

  16. noris

    Thank you. Your example really helped me.

  17. All You Need About Tooltip JQuery Tools, Best 100 !

    [...] Sexy Tooltip using CSS3 | Demo [...]

  18. martin

    Is it possible to add a delay like 500ms ?

    And if I remove the original title attribute and add the data-title attribute, will it influence the SEO?

Leave a Reply

Subscribe Me

Google Custom Search

Bookmarks