3:47 PM

Tooltips without Images

An article posted on Apr 4, 2009.

I've written quite a few blog posts over the years relating to how to perform certain tasks. However, more often than not, I find it hard to show off a working demo. Starting today, all my "demo" blog posts will also have a link to a fully working example. Should help out people who just like to look at the source of how things work.

Now, onto today's topic, tooltips without images. They work by using some simple CSS to create an object that looks like a triangle instead of doing so with an image.

.notice {
	color:white;
	padding:10px;
	background-color:black;
	width:300px;
}
.notice .pointer {
	float:left;
	width:0;
	border-left:10px solid transparent;
	border-right:10px solid transparent;
	border-top:20px solid black;
	border-bottom:0;
}

The "float" option dictates which side of the tooltip the arrow will reside on. Similarly, flipping border-top and border-bottom will reverse the direction of the arrow. Changing the border widths will alter the size and scale of the arrow.

Now, just throw the elements together in some DIVs, and it should turn out like the example at the top of the page.

<div class="notice">
	This is some example text to be placed inside the tooltip.
	<div class="pointer"></div>
</div>

Check out the demo at http://demo.1080degrees.net/tooltip/.

2 Comments

Avatar
Pablo Impallari
Nice trick. But not very reliable.
Tested on PC, this are the results:
Works great only on Firefox 3.0.8 and Google Crome.
Fails great on IE 6 & 7.
Works in some cases and not in others on Safari 4 Public Beta.
Avatar
David
I suppose I'm banking on the fact that some people won't mind if the pointer doesn't show. It's a very hacked way to create an arrow, and I don't necessarily suggest it for those who need extensive cross browser compatibility. Any chance you tried it in IE8 for fun?

Leave a Response

Name
Required.
Email Address
Won't be Published.
Comment
Copyright © 2004-2010 1080degrees. All rights reserved. Hosted by Dreamhost.