Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Rollover from Image to text

Status
Not open for further replies.

Slimsteve

Technical User
Jun 10, 2003
67
GB

Is it possible to rollover from an image to plain text, if so what is the best way to do that?

Thanks

Steve
 
Hi

Like this ?
CSS:
[purple].roll[/purple] img [teal]{[/teal] [blue]display:[/blue] [green]inline[/green]; [teal]}[/teal]
[purple].roll[/purple] span [teal]{[/teal] [blue]display:[/blue] [green]none[/green]; [teal]}[/teal]
[purple].roll[/purple][teal]:[/teal]hover img [teal]{[/teal] [blue]display:[/blue] [green]none[/green]; [teal]}[/teal]
[purple].roll[/purple][teal]:[/teal]hover span [teal]{[/teal] [blue]display:[/blue] [green]inline[/green]; [teal]}[/teal]
HTML:
[b]<span[/b] [maroon]class[/maroon][teal]=[/teal][green][i]"roll"[/i][/green][b]>[/b]
[b]<img[/b] [maroon]src[/maroon][teal]=[/teal][green][i]"whatever.png"[/i][/green][b]>[/b]
[b]<span>[/b]Whatever in words[b]</span>[/b]
[b]</span>[/b]
Note that Explorer 6 is unable to handle the [tt]:hover[/tt] pseudo-selector for other elements than [tt]a[/tt].

Feherke.
 
Couldn't get it to work Feherke, but this method works o.k across the major browsers. FF, IE8, Safari and Chrome.

Code:
a.rollover{
width:80px; [green]Width and height should match image dimensions, to avoid changes, and page jumping[/green]
height:25px;
display:block; 
background-image:url('image.png');
}

a.rollover span{
display:none;
}


a.rollover:hover{
background-image:none;
}

a.rollover:hover span{
display:inline;
}
</script>
<body>
<a href="#" class="rollover" ><span>rollover Text</span></a>
</body>

And it validates too.

----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Thanks for all the help, I have now got this working and it is much better than the java script alternatives. :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top