Hi,
Well this example means that the normal state of the images must be in the html. This has the added benefit that you can add alt and title tags as well anyway.
The idea is just to put some text in a span that sits underneath the anchor. Although the text isn't a link it will act as a link because the anchor is on top of the text but the anchor is just not visible.
The only drawback is to make sure that the text takes up less room than the image otherwise it will peek out the sides.
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<style type="text/css">
ul, li {
margin:0;
padding:0;
list-style-type:none;
}
li {float:left}
li#img1 a {display:block;width:155px;height:102px;background: url(images/pmoblogof.jpg) no-repeat left top;}/*over state of image*/
li#img2 a {display:block;width:200px;height:35px;background: url(images/pobnavdown.jpg) no-repeat top left;}/*over state of image*/
li#img2 {margin-top:67px;}/* line second image up with first*/
ul#nav li a:hover {visibility:visible}/* ie needs this */
ul#nav li a:hover img {visibility:hidden}/* hide image on hover to let background show through */
ul#nav li a, ul#nav li, ul#nav li a img {position:relative;z-index:2;}/* set z-indexes */
ul#nav li span {position:absolute;left:0;bottom:0;z-index:1;text-decoration:underline;}/* make span text appear as though its a link */
#nav li img {border:none}/* turn borders off on images */
</style>
</head>
<body>
<ul id="nav">
<li id="img1"><span>text1</span><a href="#"><img src="images/pmoblogog.jpg" alt="link1" width="155" height="102" /></a></li>
<li id="img2"><span>text2</span><a href="#"><img src="images/pobnavup.jpg" alt="link2" width="200" height="35" /></a></li>
</ul>
</body>
</html>
The code is commented so you should be able to work it out.
Paul
Bookmarks