Sign up ×
Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute:

So I have the following example image...I have the idea that this image would start off without the green tint. When the user mouses over this area it would turn green as well as be a link.

example

I have several areas, this is just an example.

I was thinking I could split the image up into several slices and align them with divs to form the picture, then use a mouse over for each slice to have it change to green tint.

Is there a better method?

share|improve this question

closed as off-topic by Simon Arnold, Matt, TheCodeArtist, Canavar, Hong Ooi Aug 2 '13 at 14:47

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist" – Matt, TheCodeArtist, Hong Ooi
If this question can be reworded to fit the rules in the help center, please edit the question.

    
Ahh I love it when people put things on hold without any inclination of why! Good job mods way to stump knowledge from spreading! @Matt – Josh Cox Aug 2 '13 at 18:56
    
Ahh I love it when people put things on hold without any inclination of why! Good job mods way to stump knowledge from spreading! @Simon Arnold – Josh Cox Aug 2 '13 at 18:59

2 Answers 2

up vote 1 down vote accepted

ImageMapster

ImageMapster is a jQuery plugin that lets you activate HTML image maps without using Flash. It works just about everywhere that Javascript does, including modern browsers, Internet Explorer 6, and mobile devices like iPads, iPhones and Android.

share|improve this answer
    
I will check it out in a bit! Thanks for your reply. – Josh Cox Aug 1 '13 at 16:47
    
This is an excellent tool and I appreciate your response! – Josh Cox Aug 2 '13 at 19:05

If you have several sections of one photo changing, you are on the right track with your thoughts.

Instead of using javascript, you could easily use css. Create the divs as you described and line them all up correctly. Instead of actually putting the image in the markup, put the link in the markup and use css to make the image a background of the link and set the link display to block so the entire div becomes clickable.

It would be something like this for the html of one piece:

<div id="slice1" class="slice"><a href="#"></a></div>

and the css would be something like:

.slice a
{
    display: block;
}
#slice1
{
    width: 100px;
    height: 100px; /* set your actual width/heights */
    background-image: url(path_to_your_image);
    background-position: center top;
}
#slice1:hover
{
    background-position: center bottom;
}

With this example, your background image file would be 2 images, the image when first loaded, and then the hover image directly below. When you change the background-position on the hover, you are showing the image below. This also eliminates the annoying version of changing the background image and getting the white flash on the first hover.

This would not require any javascript coding, external javascript libraries or other dependencies.

This was written very quickly so you may need to make some adjustments but that will get you started.

share|improve this answer
    
Awsome thanks for your reply! – Josh Cox Aug 1 '13 at 16:46

Not the answer you're looking for? Browse other questions tagged or ask your own question.