Cell Rollover Colours

TimMorgan's picture

They have: 14 posts

Joined: Feb 2006

Hi,

Please can someone help me with telling me how i can have a cell with a hyperlink in it where when you rollover the cell, the box changes colour?

Thanks

Megan's picture

She has: 11,421 posts

Joined: Jun 1999

I've done this with lists but not with tables so I'm not sure how well this technique would work on a table. Basically, what you do is increase the padding on your a tag so it fills the spcae you want. The table or list itself would have no padding. Then change the background colour on hover.

Check my personal site for an example using a list.

robfenn's picture

He has: 471 posts

Joined: Jun 2005

TimMorgan's picture

They have: 14 posts

Joined: Feb 2006

Yeah thats the one robfenn.

How did you do that then?

robfenn's picture

He has: 471 posts

Joined: Jun 2005

Well in truth, i just took it from a Javascript website.

Code for header:

<script language="javascript"type="text/javascript">
/*
Change Cell Backgrounds -
© Shivaji Basu (shivbasu.com)
To add more shock to your site, visit DHTML Shock.com
*/

function cOn(td){
if(document.getElementById||(document.all && !(document.getElementById))){
td.style.backgroundColor="#588EC0";
}
}

function cOut(td){
if(document.getElementById||(document.all && !(document.getElementById))){
td.style.backgroundColor="#FFFFFF";
}
}
</script>

Example Table:

 + Virtual Tour

DaveyBoy's picture

They have: 453 posts

Joined: Feb 2003

I don't think you need a java script for it :

TimMorgan's picture

They have: 14 posts

Joined: Feb 2006

Yeah that does the job, nice one cheers DaveyBoy.

dk01's picture

He has: 516 posts

Joined: Mar 2002

That is javascript actually. Its just embedded instead of being put in a script tag. Good solution but it won't show up if JS is turned off.

robfenn's picture

He has: 471 posts

Joined: Jun 2005

But then no one turns Javascript off...

DaveyBoy's picture

They have: 453 posts

Joined: Feb 2003

Yeah just saying you don't need the big script at the top of the page Wink

A few people do turn javascript off but well not enough to worry about i'd say.

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.