CSS Image Maps
Below is a sample image map that's built entirely using CSS and XHTML While I've added support for Javascript (item titles are simply displayed beneath the image), I've disabled it in this example -. I've run into a bit Of A Problem When JS Is Enabled and CSS IS Disabled.
The Initial Idea For this Came from A Blog Posting i read over AT Gina Trappini's Blog, Scribbling.Net. Her Example Was WALL DONE, But I Wanted to Attempt The Same (OR Similar) Using Only CSS.
I then found a link to The Daily Kryogenix site (via Gina's post) that led to an image map that made use of ligher DHTML, and made use of the
In the end, I decided to make use of doug bowman's sliding doors technique combined with a definition list (
The sliding doors technique allows you to contain all your image rollover effects in one image file, and make use of the background-position CSS property to "shift" the image in any direction By adding a:. Hover effect to your CSS (in this Case to the tag contained within the
What I did was build the image map in Photoshop. As you can see by this image, the map is made up of 3 copies of the same image, each with different markings. The top (1 of 3) simply marks the hotspots with numbers , and middle and bottom images (2 and 3 of 3) each contain the rollover effects (white transparancy). You may be wondering why the rollover effect is separated into two separate images. The reason for the separation is due to the overlap in adjacent items. (ie: the monitor, the notebook and the floppy disk on the desk) Rather than having a collision between the two items, the rollover effects for neighboring items were separated onto multiple copies of the same image.Essentially, the way this works IS by placespot intle of the item hotspot int t definition-term tag (
The code also degrades gracefully. An tag, which displays a non-mapped version of the image map, is hidden using CSS. For those who have CSS disabled, the mapped version of the image (3-piece image) does not display, since it is part of the background CSS property. Rather the non-mapped version will display, along with an unstyled definition list. If you've got the Web Developer extension for Firefox, go ahead and disable styles. you'll get a better idea of the degread.a sample of the code is displayed Below (View Source for Full CSS and XHTML):
CSS:
DD # MonitorDef {TOP: 65px; Left: 114px;} DD # monitor; width: 73px; height: 69px; text-decoration: none;} DD # monitorDef a span {display: none;} DD # MonitRDef A: Hover {Position: Absolute; Background: Transparent URL (Office.jpg) -109px -317px no-repeat; top: -10px; Left: -5px;} DD # monitorDef A: Hover span {display: block; text -indent: 0;, color-color: # f4f4f4; font-weight: bold; position: absolute; border: 1px solid #bcbcbc; bottom: 100%; Margin: 0; Padding : 5px; width: 250%;
HTML:
Monitor
Here's My 17 "Monitor. I wish i had an lcd!
2. Phone
Does this thing EVER STOP RINGING?
3. PC Case
This is my crazy linux box! Gotta love trat Linux ...
4. IBM ThinkPad
Here's My Linux Notebook. Some Crazy Coding Going On.
5. EXTERNAL FLOPPY Drive
FLOPPY Drive. Ancient ... i know!
While this may not be the most "ideal" solution out there, it certainly expands upon the examples listed above. I absolutely loved Gina's idea, which is why I attempted to expand on it. Unfortunately, with the current limitations of CSS (as well as certain browsers), I was not able to fully replicate the exact functionality of Gina's example.Here's an example that makes use of both CSS and Javascript. One problem I ran into is when CSS is disabled, but Javascript is enabled. Something weird Occurs with the definition list. if you know how to correct this, let me know. I'd love to get it working.
I did manage to come across another attempt at a CSS-based image map, which looks really great Unfortunately, due to IE's limitations. (Specifically with only support of the: hover effect on the tag), it's not cross-browser Compatible (YET!).
If you have any questions, converns, and / or suggestions for improvement, please feel: frankmanno [-t-] gmail [-dot-] COM.
The Examples Have Been Succesfully Tested in Safari, Firefox (Mac / WIN), IE6 / WIN, AND Opera 7.5 / Mac. For Some Odd Reason, The JavaScript Version Works in IE5 / Mac, WHEREAS The Non-JavaScript Version Doesn't.
Copyright © 2004
Frank Manno.