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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change background colour on mouse over 1

Status
Not open for further replies.

jaredc

Programmer
Jun 28, 2002
43
GB
Hi

I have a number of links contained within the TD element of a TABLE. I'm using CSS to make the text link change color on mouseover. What I'm wondering is whether I can make the background colour of the whole TD cell change colour on a mouse rollover rather than just the background colour behind the text itself. I would like to keep the text hyperlink (rather than use images as links). The code I've got so far is as follows:
Code:
<STYLE>
a.MainLink 
{
color: #666666;
font-family: Arial;
font-size: 9pt;
text-decoration: underline;
background-color: #CC9933;
}

a.MainLink:hover
{
color: #999999;
font-family: Arial;
font-size: 9pt;
text-decoration: none;
background-color: #FFCC66;
}

</STYLE>
<BODY>
<TABLE WIDTH=100% CELLSPACING=0 CELLPADDING=0>
	<TR>
		<TD WIDTH=20% BGCOLOR=#CC9933 ALIGN=CENTER>
		</TD>
		<TD WIDTH=10% ALIGN=CENTER BGCOLOR=#CC9933>
		<A HREF=&quot;&quot; CLASS=&quot;MainLink&quot;>Home</A>
		</TD>
		<TD WIDTH=70% BGCOLOR=#CC9933 ALIGN=CENTER>
		</TD>
	</TR>
</TABLE>
Hope this makes sense and any advice or help would be very much appreciated
Mike
 
Code:
...
<SCRIPT LANGUAGE=&quot;JAVASCRIPT&quot;>
function back(id, colour)
{
  if(document.all)
    var prefix=document.all[id].style;
  else
    var prefix=document.layers[id];

  prefix.background=colour; 
}
</SCRIPT>
</HEAD>

<BODY>
<TABLE WIDTH=100% CELLSPACING=0 CELLPADDING=0>
<TR>
  <TD WIDTH=20% BGCOLOR=#CC9933 ALIGN=CENTER></TD>
  <TD WIDTH=10% ALIGN=CENTER BGCOLOR=#CC9933 ID=cell1><A HREF=&quot;&quot; CLASS=&quot;MainLink&quot; onMouseOver=&quot;back('cell1','#FFFFFF');&quot; onMouseOut=&quot;back('cell1','#CC9933')&quot;>Home</A></TD>
  <TD WIDTH=70% BGCOLOR=#CC9933 ALIGN=CENTER></TD>
</TR>
</TABLE>
...
Tony
reddot.gif WIDTH=500 HEIGHT=2 VSPACE=3

 
Thanks very much Tony, that was exactly what I was after! Javascript to the rescue!

Cheers
Mike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top