It is possible to make the single image required for the rollover using nothing more complicated than 'irfanview' and 'MS Paint'.
get irfanview for free here.
We start with this image -apple.jpg - which measures 360px by 280px.
Open the the image in ifanview.
- click the 'image' tab.
- click 'convert to greyscale'.
- click the 'file' tab.
- click 'save as'.
- in the 'dialog box' - enter 'File name' - (say)....apple1.
- set the 'Save as type' to...JPEG.
Now open 'NotePad'.
- use this code....<img src="apple.jpg"><img src="apple1.jpg">...making sure the two images are on one line.
- save as (say)....two_images.html
Press 'Print Screen' on the keyboard and open up 'Paint'
- click the 'Edit' tab.
- click 'Paste'.
- this will load the page containing the 'raw' double image.
- click the 'select' button on the tool bar - looks like a dotted rectangle.
- set the 'cross hair' at the top left hand corner of the image.
- with left mouse down drag to the bottom right hand corner and release mouse.
- click the 'Edit' tab.
- click 'Copy'.
- click the 'File' tab.
- click 'New'.
- in the 'dialog box' - 'Save changes to untitled' - click 'No'.
- click the 'Edit' tab.
- click 'Paste'.
- you will now have the finished image.
- click the 'File' tab.
- click 'Save As'.
- in the 'dialog box' - enter 'File name' - (say).... two_apples.
- set the 'Save as type' to...JPEG.
- set the location directory in the 'Save in' box.
- click 'Save'.
- close 'Paint'.
Notice that 'Paint' saves as .JPG rather than .jpg.
We now have the final rollover image - two_apples.JPG - which measures 720px by 280px.
Well, that's the hard work done, now onto the simple task.... the code.
The image will be set as a background of an anchor element, the rollover being achieved by shifting the image half its width to the right. Now isn't that easy.
CODE
<!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" xml:lang="en" lang="en">
<head>
<title>single image rollover</title>
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8"/>
<meta name="Content-Script-Type" content="text/javascript"/>
<meta name="Content-Style-Type" content="text/css"/>
<style type="text/css">
/*<![CDATA[*/
#container {
width:360px;
border:6px double #000;
margin:174px auto;
}
#container a {
display:block;
width:360px; /*this value is half the image width*/
height:280px;
background-image:url(two_apples.JPG);
background-position:360px 0px; /* the grey apple starts at 360px*/
}
#container a:hover {
background-position:0px 0px; /* the green apple starts at 0px*/
}
/*//]]>*/
</style>
<script type="text/javascript">
//<![CDATA[
//]]>
</script>
</head>
<body>
<div id="container">
<a href="#"></a>
</div>
</body>
</html>
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>single image rollover</title>
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8"/>
<meta name="Content-Script-Type" content="text/javascript"/>
<meta name="Content-Style-Type" content="text/css"/>
<style type="text/css">
/*<![CDATA[*/
#container {
width:360px;
border:6px double #000;
margin:174px auto;
}
#container a {
display:block;
width:360px; /*this value is half the image width*/
height:280px;
background-image:url(two_apples.JPG);
background-position:360px 0px; /* the grey apple starts at 360px*/
}
#container a:hover {
background-position:0px 0px; /* the green apple starts at 0px*/
}
/*//]]>*/
</style>
<script type="text/javascript">
//<![CDATA[
//]]>
</script>
</head>
<body>
<div id="container">
<a href="#"></a>
</div>
</body>
</html>
Save this as - (say)....single_image_rollover.html.
All that is left is, to check out the finished rollover here .