<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>stormdamage.org &#187; tooltips</title>
	<atom:link href="http://stormdamage.org/tag/tooltips/feed/" rel="self" type="application/rss+xml" />
	<link>http://stormdamage.org</link>
	<description>Art, Webdesign and CSS.</description>
	<lastBuildDate>Mon, 10 Nov 2008 16:31:23 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Uses for CSS Tooltips &amp; Images</title>
		<link>http://stormdamage.org/uses-for-css-tooltips-images/</link>
		<comments>http://stormdamage.org/uses-for-css-tooltips-images/#comments</comments>
		<pubDate>Thu, 24 Jul 2008 10:50:36 +0000</pubDate>
		<dc:creator>Leonie</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[tooltips]]></category>

		<guid isPermaLink="false">http://stormdamage.org/?p=20</guid>
		<description><![CDATA[You may remember a previous post of mine, where I explained a method of using only CSS to create tooltips. Well here are two creative uses for that technique. Firstly &#8211; this map of the capital cities in the UK and Ireland. The locations are revealed when you hover your mouse over them:DublinEdinburgh  London [...]]]></description>
			<content:encoded><![CDATA[<p style="padding-bottom:0;">You may remember a previous post of mine, where I explained <a href="/tooltips-using-css-only-no-javascript/">a method of using only CSS to create tooltips</a>. Well here are two creative uses for that technique. Firstly &#8211; this map of the capital cities in the UK and Ireland. The locations are revealed when you hover your mouse over them:</p><div class="iecenter"><div id="map"><a href="javascript:void;" class="tooltip"><div class="dublin"><div class="dot"><span>Dublin</span></div></div></a><a href="javascript:void;" class="tooltip"><div class="edinburgh"><div class="dot"><span>Edinburgh </span></div></div></a><a href="javascript:void;" class="tooltip"><div class="london"><div class="dot"><span> London </span></div></div></a><a href="javascript:void;" class="tooltip"><div class="cardiff"><div class="dot"><span> Cardiff </span></div></div></a><a href="javascript:void;" class="tooltip"><div class="belfast"><div class="dot"><span>Belfast </span></div></div></a></div></div><p>This is done by creating a &lt;div&gt; which has the map image as the background. Links are placed inside this &lt;div&gt; for each location, and are positioned absolutely over the map. Inside each link is the tooltip text &lt;span&gt;, and a &lt;div&gt; with the class &#8216;dot&#8217; to define the hotspot area. On the map shown, I have outlined these divs with a square, white border so you can see where they are. But of course you could make them entirely invisible if you wanted to.<span id="more-20"></span></p>
<p>Here&#8217;s the HTML structure:</p>
<blockquote><p>&lt;div id=&#8221;map&#8221;&gt;<br />
&nbsp;&nbsp;&lt;a href=&#8221;javascript:void;&#8221; class=&#8221;tooltip&#8221;&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&lt;div class=&#8221;dublin&#8221;&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;div class=&#8221;dot&#8221;&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;span&gt; Dublin &lt;/span&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/div&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&lt;/div&gt;<br />
&nbsp;&nbsp;&lt;/a&gt;<br />
&nbsp;&nbsp;&lt;a href=&#8221;javascript:void;&#8221; class=&#8221;tooltip&#8221;&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&lt;div class=&#8221;edinburgh&#8221;&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;div class=&#8221;dot&#8221;&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;span&gt; Edinburgh &lt;/span&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/div&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&lt;/div&gt;<br />
&nbsp;&nbsp;&lt;/a&gt;<br />
&nbsp;&nbsp;&lt;a href=&#8221;javascript:void;&#8221; class=&#8221;tooltip&#8221;&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&lt;div class=&#8221;london&#8221;&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;div class=&#8221;dot&#8221;&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;span&gt; London &lt;/span&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/div&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&lt;/div&gt;<br />
&nbsp;&nbsp;&lt;/a&gt;<br />
&nbsp;&nbsp;&lt;a href=&#8221;javascript:void;&#8221; class=&#8221;tooltip&#8221;&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&lt;div class=&#8221;cardiff&#8221;&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;div class=&#8221;dot&#8221;&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;span&gt; Cardiff &lt;/span&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/div&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&lt;/div&gt;<br />
&nbsp;&nbsp;&lt;/a&gt;<br />
&nbsp;&nbsp;&lt;a href=&#8221;javascript:void;&#8221; class=&#8221;tooltip&#8221;&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&lt;div class=&#8221;belfast&#8221;&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;div class=&#8221;dot&#8221;&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;span&gt; Belfast &lt;/span&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/div&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&lt;/div&gt;<br />
&nbsp;&nbsp;&lt;/a&gt;<br />
&lt;/div&gt;</p></blockquote>
<p>So to recap &#8211; the tooltip text and &#8216;dot&#8217; hotspot are contained within a &lt;div&gt; named the class of the city it points to. This div is positioned absolutely over the map image. To create the tooltip, reuse the CSS from <a href="/tooltips-using-css-only-no-javascript/">my previous tutorial</a> (only with slightly different sizes and colours this time):</p>
<blockquote><p>a.tooltip:hover { font-size:100%; } /* IE6 fix */
a.tooltip span {display:none; }
a.tooltip:hover span { display:inline; position:absolute; padding:3px; background-color:#eee; border:1px solid #000; text-decoration:none; color:#7A2141; font-weight:bold; }</p></blockquote>
<p>Then create the CSS for the map image, and the locations:</p>
<blockquote><p>#map { position:relative; background:url(ukmap.png) no-repeat; width:244px; height:253px; border:1px solid #000; }
<br /><br />
a.tooltip div.belfast { position:absolute; top:116px; left:90px; }<br />
a.tooltip div.dublin { position:absolute; top:147px; left:80px; }<br />
a.tooltip div.edinburgh { position:absolute; top:92px; left:142px; }<br />
a.tooltip div.london { position:absolute; top:204px; left:179px; }<br />
a.tooltip div.cardiff { position:absolute; top:196px; left:130px; }</p></blockquote>
<p>Finally, create the CSS for the dot hotspots. This just decides how big each hotspot should be, and adds an optional border:</p>
<blockquote><p>a.tooltip div.dot { width:10px; height:10px; border:#fff 1px solid; }</p></blockquote>
<p>This will give you some working map tooltips! Of course, you may wish to position them a little better, as they overlap the dots a little. So you can either simply push them down a little like this:</p>
<blockquote><p>a.tooltip div span { top:14px; }</p></blockquote>
<p>or you can try and centre them:</p>
<blockquote><p>a.tooltip div span { top:14px; margin-left:-250%; font-size:100%; }</p></blockquote>
<p>Unfortunately this method is not terribly reliable, a better solution would be to make all the tooltip text &lt;span&gt; tags the same width, then negatively offset them by half their width:</p>
<blockquote><p>a.tooltip div span { text-align:center; top:14px; width:60px; margin-left:-30px; font-size:100%; }</p></blockquote>
<p>The second use for this CSS technique would be a Facebook style method of highlighting photographs. A list of items is shown under an image. When the mouse is hovered over one of the items, a box appears on the image. Like so:</p>
<div class="iecenter"><div class=housemates style="text-align:left;"><ul><li><a href=# class=person>Jon <span class=jon></span></a></li><li><a href=# class=person>Leonie <span class=leonie></span></a></li><li><a href=# class=person>Andy<span class=andy></span></a></li></ul></div></div>
<p>To do this, you need to create a &lt;div&gt; which will hold the image and the list. Each list item will have a &lt;span&gt; inside it, which will be hidden initially, but show up over the image when the item is hovered over. Here&#8217;s the HTML:</p>
<blockquote><p>&lt;div class=&#8221;housemates&#8221;&gt;<br />
&nbsp;&nbsp;&nbsp;&lt;ul&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;li&gt;&lt;a href=&#8221;#&#8221; class=&#8221;person&#8221;&gt;Jon &lt;span class=&#8221;jon&#8221;&gt;&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;li&gt;&lt;a href=&#8221;#&#8221; class=&#8221;person&#8221;&gt;Leonie &lt;span class=&#8221;leonie&#8221;&gt;&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;li&gt;&lt;a href=&#8221;#&#8221; class=&#8221;person&#8221;&gt;Andy &lt;span class=&#8221;andy&#8221;&gt;&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;<br />
&nbsp;&nbsp;&nbsp;&lt;/ul&gt;<br />
&lt;/div&gt;</p></blockquote>
<p>The &#8216;housemates&#8217; div should have the photo as a background, and have the photograph&#8217;s width plus some top padding to push the list down underneath:</p>
<blockquote><p>.housemates { position:relative; background:url(housemates.jpg) no-repeat; width:419px; padding-top:343px; }</p></blockquote>
<p>Then the size of the spans which appear when hovering should be set, using the CSS trick previously outlined:</p>
<blockquote><p>a.person:hover { font-size:100%; } /* IE6 fix */<br />
a.person:hover span { position:absolute; width:80px; height:100px; background:transparent; border:2px solid #fff; text-decoration:none; }</p></blockquote>
<p>Finally each individual &lt;span&gt; is given a position over the image:</p>
<blockquote><p>a.person span.jon { top:35px; left:72px; }<br />
a.person span.leonie { top:39px; left:157px; }<br />
a.person span.andy { top:30px; left:240px; }</p></blockquote>
<p>And there it is, a simple way of using CSS to annotate your photos, Facebook style.</p>
]]></content:encoded>
			<wfw:commentRss>http://stormdamage.org/uses-for-css-tooltips-images/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
