-
Aug11
-
CSS Image Maps: A Beginner’s Guide
-
While they may not be used as often as they once were in the heyday of table based web design, image maps can still be quite useful in situations that call for it. Unfortunately, for beginners, achieving this with CSS alone, can be a difficult concept to grasp.
In this tutorial, we're not only going to get you up to speed on how to create a CSS image map, but, we're also going to take it a couple steps further and add hover states to our image map using a CSS background image sprite, as well as a "tooltip" like popup.
Introduction
In the days of table based web design, using image maps in your web layouts were quite common. They were used to define clickable areas, or "hotspots", within several sliced images (coming together to form one image). During this time, these hotspots were used mostly for navigational purposes. Today, image maps created in CSS are not only a much leaner and cleaner markup, but they're also easily editable and are often used for displaying additional content when hovered, not just as a means of navigation.
Before we get started, let's take a look at an old school image map using tables. First of all, the majority of interface designers used an image editing program like Fireworks or Photoshop to slice the image into its separate sections, and then exported it into HTML using tables.
What you'd end up with is 17 images, a spacer gif, and a mess of table rows and very un-semantical markup.
<table id="Table_01" width="581" height="271" border="0" cellpadding="0" cellspacing="0"> <tr> <td colspan="3" rowspan="2"> <a href="http://en.wikipedia.org/wiki/North_America"> <img src="images/North-America.png" width="193" height="135" border="0" alt=""></a></td> <td colspan="2"> <img src="images/index_02.png" width="21" height="83" alt=""></td> <td colspan="2"> <a href="http://en.wikipedia.org/wiki/Europe"> <img src="images/Europe.png" width="119" height="83" border="0" alt=""></a></td> <td colspan="2" rowspan="2"> <a href="http://en.wikipedia.org/wiki/Asia"> <img src="images/Asia.png" width="163" height="135" border="0" alt=""></a></td> <td colspan="2" rowspan="3"> <img src="images/index_05.png" width="84" height="165" alt=""></td> <td> <img src="images/spacer.gif" width="1" height="83" alt=""></td> </tr> <tr> <td rowspan="5"> <img src="images/index_06.png" width="14" height="187" alt=""></td> <td colspan="2" rowspan="3"> <a href="http://en.wikipedia.org/wiki/Africa"> <img src="images/Africa.png" width="123" height="138" border="0" alt=""></a></td> <td rowspan="5"> <img src="images/index_08.png" width="3" height="187" alt=""></td> <td> <img src="images/spacer.gif" width="1" height="52" alt=""></td> </tr> <tr> <td rowspan="4"> <img src="images/index_09.png" width="86" height="135" alt=""></td> <td rowspan="4"> <a href="http://en.wikipedia.org/wiki/South_America"> <img src="images/South-America.png" width="92" height="135" border="0" alt=""></a></td> <td rowspan="4"> <img src="images/index_11.png" width="15" height="135" alt=""></td> <td colspan="2"> <img src="images/index_12.png" width="163" height="30" alt=""></td> <td> <img src="images/spacer.gif" width="1" height="30" alt=""></td> </tr> <tr> <td rowspan="3"> <img src="images/index_13.png" width="99" height="105" alt=""></td> <td colspan="2" rowspan="2"> <a href="http://en.wikipedia.org/wiki/Australia"> <img src="images/Australia.png" width="101" height="79" border="0" alt=""></a></td> <td rowspan="3"> <img src="images/index_15.png" width="47" height="105" alt=""></td> <td> <img src="images/spacer.gif" width="1" height="56" alt=""></td> </tr> <tr> <td colspan="2" rowspan="2"> <img src="images/index_16.png" width="123" height="49" alt=""></td> <td> <img src="images/spacer.gif" width="1" height="23" alt=""></td> </tr> <tr> <td colspan="2"> <img src="images/index_17.png" width="101" height="26" alt=""></td> <td> <img src="images/spacer.gif" width="1" height="26" alt=""></td> </tr> <tr> <td> <img src="images/spacer.gif" width="86" height="1" alt=""></td> <td> <img src="images/spacer.gif" width="92" height="1" alt=""></td> <td> <img src="images/spacer.gif" width="15" height="1" alt=""></td> <td> <img src="images/spacer.gif" width="14" height="1" alt=""></td> <td> <img src="images/spacer.gif" width="7" height="1" alt=""></td> <td> <img src="images/spacer.gif" width="116" height="1" alt=""></td> <td> <img src="images/spacer.gif" width="3" height="1" alt=""></td> <td> <img src="images/spacer.gif" width="99" height="1" alt=""></td> <td> <img src="images/spacer.gif" width="64" height="1" alt=""></td> <td> <img src="images/spacer.gif" width="37" height="1" alt=""></td> <td> <img src="images/spacer.gif" width="47" height="1" alt=""></td> <td></td> </tr> </table>
If you take a look at the page, you'll notice it does exactly what it's supposed to do. It's when you look "under the hood" you'll see the mess, not to mention, adding additional functionality to the image map, like hover states, usually requires javascript.
Semantics and the taboo of table based web design aside, how much of a nightmare is it to edit that? I mean, if you decided to change the source image whatsoever there's a lot of legwork to be done to re-export it into HTML, especially if your 17 images becomes 25 images. My stomach turns just to think about it.
What we're going to do is cut the HTML into a fraction of what you see above, while using only one image and CSS. Before we do, let's take a look at what we're going to be covering in this tutorial.
- Recreate our image map using CSS
- Add hover states using a CSS background sprite
- Create a "tooltip" like pop-up when hovering "hotspots"
First, we'll be recreating the above mess in a much leaner, easily manageable, and semantic way. Once we get our feet wet and get comfortable with how CSS image maps work, we'll kick it up a notch and use a CSS background image sprite to add some hover states to our image map. Lastly, as if that wasn't enough, we'll take it even one step further and demonstrate how an image map's use is not necessarily restricted to its navigational purposes, but proves to be quite useful in providing additional information about specific sections of the image map using a "tooltip" like pop-up.
Noobnote:
As pointed out in the comments, I don't want to confuse a beginner with the HTML map tag and image slicing. I refer to the above example as "image map" when, in all actuality, it is a way of slicing and image into a table and creating its hotspots that way. I have always just referred to both ways as image mapping, and I apologize for any confusion.
Recreate our image map using CSS
In the table based image map, I used Photoshop to slice my continents map into 17 different images to be used for my 6 hotspots, or clickable links. In our CSS image map, we're only going to use one image.
map-color.png
Apparently Wikipedia didn't want to include Antarctica in the continents map so we'll be working with 6 instead of 7! Oh well, the important lesson here is CSS image maps, not geography.
What we're going to do is create an unordered list and use our map-color.png as its background-image. Fire up your text-editor of choice and create a new html document with the following markup in it:
<ul id="continents"> <li id="northamerica"><a href="http://en.wikipedia.org/wiki/North_America">North America</a></li> <li id="southamerica"><a href="http://en.wikipedia.org/wiki/South_America">South America</a></li> <li id="asia"><a href="http://en.wikipedia.org/wiki/Asia">Asia</a></li> <li id="australia"><a href="http://en.wikipedia.org/wiki/Australia">Australia</a></li> <li id="africa"><a href="http://en.wikipedia.org/wiki/Africa">Africa</a></li> <li id="europe"><a href="http://en.wikipedia.org/wiki/Europe">Europe</a></li> </ul>What we have here is a simple unordered list containing our 6 continents and links to their information on wikipedia.org.
Let's add some basic styles to our ul element.
ul#continents { list-style: none; background: url(images/map-color.png) no-repeat 0 0; position: relative; width: 580px; height: 268px; margin: 0; padding: 0; }Some basic styles here, nothing special. We removed the list-style, added a background image, declared its width and height to be the same as our background image, and reset the margins and padding. The important declaration to pay attention to here is its position value of relative. This will allow for us to absolutely position our li elements next. You should have something like this.
Now we need to position our li elements according to their size and location on the continents map.
To make it easier for positioning our li elements, I recommend adding a 1px border to each li element, to guide us as a wireframe. We can remove the border when we're done positioning our li elements. Also, because all of our li elements will have this border AND also have a position value of absolute, rather than repeating ourself on each element's declarations, let's add them to all the li elements in our unordered list. Below your ul#continents styles add the following styles:
ul#continents li { border: 1px solid #000; position: absolute; }If you look at the page now, you'll see all of our li elements all bunched up in the left hand corner, overlapping one another. This is because they all have an absolute position, but there aren't any left, top, right, or bottom property values declared yet. We'll do that next.
Right below the ul#continents li styles, add the following styles:
#northamerica { width: 227px; height: 142px; top: 2px; left: 0px; } #southamerica { width: 108px; height: 130px; top: 131px; left: 76px; } #africa { width: 120px; height: 140px; top: 83px; left: 209px; } #europe { width: 120px; height: 84px; top: 1px; left: 211px; } #asia { width: 215px; height: 175px; top: 1px; left: 283px; } #australia { width: 114px; height: 95px; top: 152px; left: 432px; }All we did was give each li element its respected height and width values, and also positioned each of them using the left and top properties.
Noobnote:
An easy way to get an idea of where to start with our left and top properties, I simply used Photoshops rectangle marquee selection tool and the "info" panel to give me an estimate. Once I had an approximate value from there, I fine tuned it in the CSS declarations.

Now if you take a look at our page, you'll see a nice little wireframe of our image map. This is where the borders come in handy for fine tuning the positions. I think it looks good where it is, let's move on!
Right now, our li elements are only "clickable" within the text area of each anchor element. We want our entire li element to be clickable, so we need to add some styles to our anchor elements. I've highlighted the new styles needed.
ul#continents { list-style: none; background: url(images/map-color.png) no-repeat 0 0; position: relative; width: 580px; height: 268px; margin: 0; padding: 0; } ul#continents li { border: 1px solid #000; position: absolute; } ul#continents li a{ display: block; height: 100%; text-indent: -9000px; } #northamerica { width: 227px; height: 142px; top: 2px; left: 0px; } #southamerica { width: 108px; height: 130px; top: 131px; left: 76px; } #africa { width: 120px; height: 140px; top: 83px; left: 209px; } #europe { width: 120px; height: 84px; top: 1px; left: 211px; } #asia { width: 215px; height: 175px; top: 1px; left: 283px; } #australia { width: 114px; height: 95px; top: 152px; left: 432px; }First thing we did was declare our display property value as block, instead of its default of inline, allowing for us to give it a height value, in which case we're giving it a value of 100%. We also gave it a negative text-indent value, because we want our text to only exist if CSS is disabled, otherwise we don't want it shown on our image map. Take a look at our page now, and hover over our "hotspots". You'll notice now that our hotspots include our entire li element now.
That's it! You can now remove the border values from your li elements and you'll have a simple CSS image map.
Not only is the markup cleaner, and easier to read, but, it's also a lot easier to make modifications to. For instance, if we went in and added Antarctica to the map, we'd simply need to create another li element and position it accordingly.
Add hover states to our map
So far we have demonstrated how to implement a simple image map using CSS, but, from a presentational standpoint, there doesn't seem to be much of a difference between the two image maps (table based vs. CSS). Where CSS image maps stand out is the ability to use a CSS background image sprite to add hover states to our image map.
I used another map from wikipedia to create a simple image sprite.
map.png
As you can see, I created a new image called map.png. I'm going to replace the map-color.png in my ul#continents styles with my new sprite image.
ul#continents { list-style: none; background: url(images/map.png) no-repeat 0 0; position: relative; width: 580px; height: 268px; margin: 0; padding: 0; }If you were to look at your page with the new background image, you wouldn't see a difference. What we need to do is add background image to our anchor elements, but only when they are hovered. What we're going to do is use the same background image as our ul#continents element on our anchor elements when they are hovered. We'll then need to position the background image according to its position within the sprite.
Let's go ahead and start with North America. At the bottom of your styles, add the following CSS rules:
ul#continents li a:hover { background: url(images/map.png) no-repeat 0 0; } ul#continents li#northamerica a:hover { background-position: 0 -270px; }What we've done is added our background image (map.png) to all of our anchor elements within the continents unordered list. We then declared the background position on our anchor element inside of the li#northamerica. If you take a look at our image map now, you'll see when you hover North America, it has a nice little hover state letting you know you're hovering over North America. If you hover the other continents, you'll see a piece of the the colored version of North America, because we haven't changed their background-positions yet. We'll do that now.
Below the last CSS rules you just put in your styles, go ahead and add the rest of the background position values.
ul#continents li#southamerica a:hover { background-position: -226px -273px; } ul#continents li#africa a:hover { background-position: -209px -417px; } ul#continents li#europe a:hover { background-position: -22px -427px; } ul#continents li#asia a:hover { background-position: -363px -268px; } ul#continents li#australia a:hover { background-position: -412px -455px; }Take a look at our image map now, and you'll see the background positions itself accordingly, when you hover over each continent.
How easy was that?! That's a nice little image map, with minimal markup, done 100% with CSS, and no javascript.
Here's our image map CSS and HTML up to this point:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>CSS Image Maps - With Hover States</title> <style type="text/css"> ul#continents { list-style: none; background: url(images/map.png) no-repeat 0 0; position: relative; width: 580px; height: 268px; margin: 0; padding: 0; } ul#continents li { position: absolute; } ul#continents li a{ display: block; height: 100%; text-indent: -9000px; } #northamerica { width: 227px; height: 142px; top: 2px; left: 0px; } #southamerica { width: 108px; height: 130px; top: 131px; left: 76px; } #africa { width: 120px; height: 140px; top: 83px; left: 209px; } #europe { width: 120px; height: 84px; top: 1px; left: 211px; } #asia { width: 215px; height: 175px; top: 1px; left: 283px; } #australia { width: 114px; height: 95px; top: 152px; left: 432px; } ul#continents li a:hover { background: url(images/map.png) no-repeat 0 0; } ul#continents li#northamerica a:hover { background-position: 0 -270px; } ul#continents li#southamerica a:hover { background-position: -226px -273px; } ul#continents li#africa a:hover { background-position: -209px -417px; } ul#continents li#europe a:hover { background-position: -22px -427px; } ul#continents li#asia a:hover { background-position: -363px -268px; } ul#continents li#australia a:hover { background-position: -412px -455px; } </style> </head> <body> <ul id="continents"> <li id="northamerica"><a href="http://en.wikipedia.org/wiki/North_America">North America</a></li> <li id="southamerica"><a href="http://en.wikipedia.org/wiki/South_America">South America</a></li> <li id="asia"><a href="http://en.wikipedia.org/wiki/Asia">Asia</a></li> <li id="australia"><a href="http://en.wikipedia.org/wiki/Australia">Australia</a></li> <li id="africa"><a href="http://en.wikipedia.org/wiki/Africa">Africa</a></li> <li id="europe"><a href="http://en.wikipedia.org/wiki/Europe">Europe</a></li> </ul> </body> </html>Create a "tooltip" like pop-up when hovering our continents
By now, you should probably have a pretty good feeling about CSS image maps and how to implement them. What we're going to do now is take it one step further and create a "tooltip" like pop-up to each of our continents when they are hovered. First thing we need to do is remove the negative text-indent declaration from our anchor elements.
ul#continents { list-style: none; background: url(images/map.png) no-repeat 0 0; position: relative; width: 580px; height: 268px; margin: 0; padding: 0; } ul#continents li { position: absolute; } ul#continents li a{ display: block; height: 100%; }Now when you view your image map, you'll notice that all the country named anchors are visible again. We're going to take care of that now.
In the HTML of our image map, wrap the text content of each of our anchor elements in a <span> tag. So our html in the body should now look like this:
<ul id="continents"> <li id="northamerica"><a href="http://en.wikipedia.org/wiki/North_America"><span>North America</span></a></li> <li id="southamerica"><a href="http://en.wikipedia.org/wiki/South_America"><span>South America</span></a></li> <li id="asia"><a href="http://en.wikipedia.org/wiki/Asia"><span>Asia</span></a></li> <li id="australia"><a href="http://en.wikipedia.org/wiki/Australia"><span>Australia</span></a></li> <li id="africa"><a href="http://en.wikipedia.org/wiki/Africa"><span>Africa</span></a></li> <li id="europe"><a href="http://en.wikipedia.org/wiki/Europe"><span>Europe</span></a></li> </ul>If you look at our image map now, you won't see any changes in our layout. Now, as I said, we only want text to show when we hover over one of our continents. So what we need to do is hide our span elements until our anchor element has been hovered. We will do this by using the display property.
Add the following CSS rules at the bottom of your styles:
ul#continents li a span { display: none; } ul#continents li a:hover span { display: block; }What we're telling the browser to do is hide all span elements (display: none) until its parent anchor element is hovered, in which, it will change from display: none to display: block.
Take a look at our image map now and hover each continent. You'll now see the text will only show when its parent anchor element has been hovered. Let's make this thing look better, and add some useful information to the span elements, rather than just the country's name.
Note: I changed the way my HTML markup looks in the unordered list code for readability, it will not render the page any differently.
<ul id="continents"> <li id="northamerica"> <a href="http://en.wikipedia.org/wiki/North_America"> <span> <strong>North America</strong> Population: 528,720,588 </span> </a> </li> <li id="southamerica"> <a href="http://en.wikipedia.org/wiki/South_America"> <span> <strong>South America</strong> Population: 385,742,554 </span> </a> </li> <li id="asia"> <a href="http://en.wikipedia.org/wiki/Asia"> <span> <strong>Asia</strong> Population: 3,879,000,000 </span> </a> </li> <li id="australia"> <a href="http://en.wikipedia.org/wiki/Australia"> <span> <strong>Australia</strong> Population: 21,807,000 </span> </a> </li> <li id="africa"> <a href="http://en.wikipedia.org/wiki/Africa"> <span> <strong>Africa</strong> Population: 922,011,000 </span> </a> </li> <li id="europe"> <a href="http://en.wikipedia.org/wiki/Europe"> <span> <strong>Europe</strong> Population: 731,000,000 </span> </a> </li> </ul>What we've done is wrap <strong> tags around our each of our continents' names and added each of their respected population counts.
Now we need to add some styles to our new elements and we're done. First thing we want to do is remove the underline from our anchor elements. Go ahead and find your ul#continents li a rules in your styles and add the highlighted style declaration.
ul#continents li a{ display: block; height: 100%; text-decoration: none; }Now we need to add some more rules to our span elements. Add the highlighted styles.
ul#continents li a:hover span { display: block; padding: 5px; width: 150px; background: #000; position: relative; top: 50%; font: 11px Arial, Helvetica, sans-serif; opacity: .75; filter:alpha(opacity=75); color: #FFF; }What we're doing here is giving our span elements (when they're parent anchor element is hovered) some styles to make our content look a little better and more like a tooltip.
Noobnote:
If you're not familiar with the opacity or filter:alpha properties, they're simply being used to drop the opacity of our span elements. Please note that these two declarations will cause your CSS to not validate. You could use javascript (jQuery) to apply the opacity settings if you wanted to, but for the sake of this demonstration I'm not going to worry about my CSS validating. Just know, without these two declarations your CSS and HTML to this point will certainly validate.
Take a look at our image map now, and you'll see we have implemented a nice little tooltip, when hovering each continent, giving us each of their populations!
Final Thoughts
That's it! Now, you should have a pretty good understanding of how CSS image maps work. You should be able to take this knowledge and use it into your own projects, or even extend its use by implementing your own ideas.
As always, if you have any questions or problems, please don't be afraid to ask in the comments.
Thanks for reading.
About the author
I love web design and development. It's what I do before bed, and what I can't wait to do when I wake up. So, what do I do when I'm not designing, coding, or dreaming about designing and coding? Well, I'm a music connoisseur, a daddy, a husband, a writer, a joker, and a friend.
Jarod TaylorEnjoy this post?
If you enjoyed this post, please take a second to retweet it, or share it via the various social bookmarking sites below. Don't forget to subscribe to the RSS Feed. If you'd rather customize your subscription options, please visit our subscription page. Thanks again for visiting us!
-
-
Pingbacks
- CSS Image Maps: A Beginner’s Guide | Noobcube
- 12-Aug-2009 | WebDesignExpert.Me
- CSS Image Maps: A Beginner’s Guide | Noobcube
- CSS Image Maps: A Beginner’s Guide | Design Newz
- CSS Brigit | CSS Image Maps: A Beginner\’s Guide
- CSS??, I vaguely recall this sea ess ess | Techmode Blog 1.1
- 30 Pure CSS Alternatives to Javascript - Speckyboy Design Magazine
- 30 Pure CSS Alternatives to Javascript | DesignerLinks | Home to Web design news, jQuery Tutorials, CSS tutorials, Web Designing tutorials, JavaScript tutorials and more!
- 30 Pure CSS Alternatives to Javascript « Royale9designs a web and graphic design studio – Web Design Services, Web Development Services, SEO Services, Graphic design services, kolhapur, India
- 30 Pure CSS Alternatives to Javascript « Film and entertainment
- 10 Best Techniques Only with CSS No JavaScript Needed | RefreshTheNet
- 50 New Useful CSS Techniques, Tools and Tutorials - Smashing Magazine
- 50 New Useful CSS Techniques, Tools and Tutorials « Vleerkatcreations
- 50 New Useful CSS Techniques, Tools and Tutorials | i know idea
- Furkan Tunalı v4 beta // 50 New Useful CSS Techniques, Tools and Tutorials /
- 彼岸(Into the wild) » Blog Archive » 50 New Useful CSS Techniques, Tools and Tutorials
- 50 New Useful CSS Techniques, Tools and Tutorials « qeqnes | Designing. jQuery, Ajax, PHP, MySQL and Templates
- The Power Of CSS:40 Totally Pure CSS Solutions Without Javascript | DesignBeep
- The Power Of CSS:40 Totally Pure CSS Effects With Demos | Afif Fattouh - Web Specialist
- 50 New Useful CSS Techniques, Tools and Tutorials « The Day I Wanna be….
- sgwebdesigning » Blog Archive » CSS Image Map
Comments
(Add Comment)-
B. MooreWhen I think of html image maps and what you showed are 2 different things.
What you called the original html image map with the tables and lots of images was “how to build a website” in 1998 in my opinion.
The link below is the original html image map:
elated.com/article…creating-image-maps/Anyways….
Thank you for showing my how to do it all in css, great tutorial!
-
darloboyExcellent tutorial, but I agree with the above commentator that the slice-and-table map is a bit of a straw man.
I’m sure there are good reasons, but it would be good to be given a sense of why it is better to define an image map using CSS rather than via the HTML ‘map’ tag:
http://www.w3schools.com/TAGS/tag_map.asp
-
DeanThere’s no such thing as CSS Image Maps. What you have is a mess of unordered lists. A picture of a world map isn’t a list of anything. See w3.org/TR/html5/th…ment.html#image-maps
-
peslaYou’ve done a great job showing the flexibility of unordered listitems and their contents when they are manipulated and positioned by CSS. I’m sure some people out there find that usefull, but it should be made clear that there are, as Dean pointed out, actually semantic ways to accomplish an image map on the web.
Please just use the map and area elements HTML offers us to build image maps. Be semantic and accessible
-
DonaldWhat a beautiful idea! Beginners looking to design an attractive website will be surely benefited through this. It would add great thing to my website! Oh so gorgeous! I would want to put everything in it. These are fantastic! I would love to implement these features for organizing the website i will make!
-
-
-
cityloveGreat tutorial ! I have to try that ! Yesterday, when I decide to do something better in my website I understood nothing from the text. Now, I think I will understand more the texte and maybe, I will be able to do a little thing on it !
Thank you so much ! -
Tony MThis work around to produce a css based navigation over an image… is actually much easier to implement with js frameworks than the traditional html thing.
you know exactly which links are going to be arrived at first every time and it makes it much easier to specifiy a trigger element. You are able to use many accordion or tabbed navigation lists out of the box. As much as I love to bend over backwards for the 0.002% of the traffic that doesn’t have the ability to see and javascript turned off completely, or images turned off… they aren’t my target audience as I target the populace as a whole, not a tiny fraction of it.
As such if it looks trick and impresses people then I will implement it after considering the pro’s and cons.
This method falls firmly into the easy but questionable camp.
good reference material. thanks -
ToftHi !
Great tutorial – very usefull !
I’m using your code (or trying…:-) to show some div’s and the hover-effect is working just fine. But I also want the hover to be visible, when the corresponding div is visible.
Maybe like an “a:active” function.
But I can get it right. Do you have any suggestions ?Regards
Toft
-
ToftHi Jarod
Thats excactly what I’m looking for.
Find the demo here: http://www.infoserver.dk/test/imagemap-room.html´
What I would really like is, if the chosen element (door, floor etc) could have a black egde (I have’nt maked that image yet), when “active” (the corresponding div is visible) and had a red egde, when something’s selected in one of the ‘s.
I also need to be able to show a red egde “on page load”, for example when the user loads a page, and some choises (ie floor or wall) already have been choosen (info from the db)
Is it in anyway possible ?
Thx again !
-
inzzzomniaThanx for the tutorial, i like the concept.
I ran in to some problems with IE6 though, and i’m not sure how to solve it…If the tooltip contains to much text, it will create an area large enough too display the ‘wrong’ parts of the hover-part of the image. For example, if North America’s tooltip contains a long list of text, parts of Europe will show up in the background.
I can see why it happens, i just can’t figure out what to do about it, please, please help!
-
inzzzomniaSuper-thanks for your quick reply!
What if spacing the images further out isn’t an option. As you see in my example here: http://www.licab.se/temp/map/af_karta.html (don’t mind the png-issue in IE6), I have quite an amount of different areas, so spacing the images further out would demand an image with a width of 5000px-ish…
Do you know if there’s another way of creating the tooltip, with javascript perhaps?
I’m so close to getting this project done, up and running, the tooltip is the final piece of the puzzle. I really appreciate your help!
-
inzzzomniaOh yeah, it works perfect!
ul#continents li a:hover span {
position: absolut;
}Now, the spacing between hover-parts of the image isn’t an issue in IE6.
Thank you!
-
Tomohey,
thanks that’s great but…
problems:
http://tomojacobson.art.pl/strona/1. i’d like it to be in the center of the page – i know it’s suppose to be easy but centering background doesn’t work…
2. i want the hover area to be smaller (just the letters f.ex. ‘P’ and ‘L’ in ‘news’), but if i make it smaller the whole ‘news’ is not visible. what to do???
thanks again, your tutorials are gr8!
-
Tomouh… and one more thing…
so look at http://tomojacobson.art.pl/strona/
and hover ‘R’, just part of ‘projects’ is visible…
headake… -
mosithanks.
very useful for me:D -
DreInterested to know if you have thoughts on adding an on-click event to initiate the tool tip instead of on-hover?
-
JenThanks for the tutorial – it seems to be exactly what I need (I think). I’m having issues with IE though and hope you can help. It looks great in FireFox, but I realize it’s quite forgiving. Here is the test page:
bloombergconsultin…com/hot_testing.html
I’d like the majority of the box clickable, not just the “Read More” button at the bottom, so I thought this tutorial would accomplish that. In IE, the text just seems to fall in line with the bottom of the “image map” instead of laying on top.
TIA for your help…
-
HelenGreat tutorial. Thanks for explaining it in such simple to understand steps and language
-
merdaI made one europe map in for the company where i work website this summer, just only css & css sprites, it was a hard job… http://www.muchosol.es
-
Tony[...] http://line25.com/tutorials/getting-started-with-css-a-practical-exercise noobcube.com/tutor…-a-beginners-guide-/ and for more, one of my favorite tutorial sites [...]
-
Free CSS MenusA very easy to follow css tutorial !
I have created a css world map:
freecssmenus.co.uk…map_rollover_629.php& a css UK map:
freecssmenus.co.uk…_rollover_uk_map.php -
SivaranjanThis is an incredible post. Its amazing to see what CSS can do . I am taking the liberty of adding this article to my CSS aggregator site. Hope you dont mind.
-
Andrés MejíaGreat post. I’m grabbing the RSS feed right now. Keep it up!
-
JamesHi there, great tutorial. Is there any way for the tooltip to show in a specific area rather than absolute? Ie top left no matter what country you rolled over? I tried it with abolsute positioning but of course it positions to the li… any ideas?
-
DanGreat tutorial, though I’m wondering how your PNG file works in IE6. When I try to create my PNG file, it doesn’t work with a transparent background. What’s the trick?
-
RenèeHi Jarod! In redesigning my site, I came across a different CSS image mapping tutorial. Same idea, just without the UL/LI attributes and such.
For everything I *do* know about coding HTML & CSS, I’m baffled by one thing: The main image that is to be used as the image map is meant to be centered on the page, and while these CSS image mapping techniques are great for left-aligned pages, it doesn’t appear to be a great alternative for centered pages.
You see, when the page is viewed in a browser at full size (mine specifically, Firefox on a resolution of 1680 x 1050), the CSS lines up perfectly on my image; however, if I resize the window, the entire thing gets thrown off, therefore making the “tabs” on my image that were clickable before, now useless.
Is there something I’m missing here with positioning of the menu (relative at the moment; tried fixed, no worky), or would it be that in the case of having centered pages, it might be better to simply use the HTML/sliced image map method instead?
Thanks a lot for your input! Much appreciated.
-
Shark11Hi!
I really like this tutorial, but I have one question. Is there any way to put in this code something like the onclick script?
-
firma rehberiHi Jarod Taylor ;
Great Tutorial. That is excactly what I’m looking for. I’ll try this tomorrow. CSS is getting more clear for me.Kinda Regards,
Natto -
KyleIs it possible to have links within the block?
-
-
-
Sean CavanaughJarod, I’ve learned a good deal of html over the past several years. In August 09 you mentioned that this was meant to be a great intro to CSS and I found it to be so.
One question, you mentioned a personal favorite, jQuery in another comment. Can you explain a little more what jQuery is and what it’s used for?
Sean
Webmaster: gouttreatmenttip.com
Gout Treatment -
Coat RackThank you for the tutorial,the screenshots make it so much easier to implement as compared to the basic help menu onPhotoshop
-
Sam OrchardThis post would’ve been extremely useful about a week ago, where I had to build something almost identical
Great post though. -
PatrykGreat tutorial!!! Thank you!
-
ramosHi Taylor , Thanks for your interesting and useful tutorial.I am currently creating an interactive Map for my own website. I have tried to see how it’s working so i used your code to get the concept as well as getting to know Css and Jquery.I am not good in both of them but i am still learning. My question is i tried to add Href Link under Africa Egypt but it didn’t work.Please Help me with this.
What i am trying to do is to add Countries under each Continent. So when i click on the continent( North America) for example i can see list of countries such as (Canada, Mexico) and each one will have a Link ( New page).so when i click on any of the countries, it will take me to its own page.
Thank you.
-
wrenDoes this work when testing in Dreamweaver? Because I’ve tried testing this and absolutely nothing happens the way its listed in the tutorial. The links continued to remain single file next to each other at the top of the image (which doesnt even show up), and nothing I did or changed cause them to move. I know that occasionally HTML/CSS done in DW will not appear to work even when it does, hence why I want to ask this before I scrap my whole project.
