Table Cell Rollover
- Started
- Last post
- 10 Responses
- barrel
I would like to have the background color change in my table cell when someone rollovers that cell. I have seen a version of it in the old http://www.37signals.com But I cannot seem to make it work with CSS. I can get the background of the text to change, but not the whole cell.
Can someone help me with this?
- mc_escher0
Try this, hope the html displays ok:
< td onMouseover="this.style.backgrou... onMouseout="this.style.backgroun... >
- mc_escher0
It's not CSS like you asked, but works just as well... plus, if you wanna link up the cell you can do:
<tr onMouseover="this.style.backgrou... onMouseout="this.style.backgroun... onclick="location.href='http://w... style="cursor:hand" bgcolor="#ffffff">
- barrel0
So you can't do it with CSS?
what you gave me works great!
Thank you.
- mc_escher0
You probably can, but I've never done it for a tr before...
- barrel0
Well thank you anyways. What you have given me work fine.
Later I would like to try to find a CSS version so that I can link it and use it over and over.
- kpl0
I'm 95% sure you need some javascript in there to make it work. ccs alone won't be able to do that kind of stuff, albeit I might try doing
td id=blah
and put
blah:hover {
blah blah: blah blah
}
in there to experiment.
- barrel0
Actually, according to this book you can do image swaps with out javascript.
But I wanted to use it like ms_escher 's code, but in css form.
- ascuro0
so can you use CSS?
- christo0
yes you can use CSS... here is a link for ya:
http://www.alistapart.com/storieā¦
I am seeing this alot more lately and its fast and clean
- sp0
Again, the reason why CSS and Tables don't play nice is because Tables are not for layout.
The DOM code will work for what you need - the "onmouseover" code you got above.
To get it to work with CSS, either use a CSS hack, or code the markup correctly using DIV and SPAN.