Can CSS do this?

H

Half Dolla 2003

I'm using this code to make TD cell backgrounds change color...

onMouseOver="style.backgroundColor='#333333'"
onMouseOut="style.backgroundColor='#000000';"

Is it necessary to put all this into every single one, or can I just use a
style tag up top? If so, what would that be?
 
G

Geoff Ball

I'm using this code to make TD cell backgrounds change color...

onMouseOver="style.backgroundColor='#333333'"
onMouseOut="style.backgroundColor='#000000';"

In your stylesheet:

a:link {
color:inherit;
background-color:#000;
}

a:hover {
color:inherit;
background-color:#333;
}

Change color to your liking, or leave it as-is to inherit the text-color.

Regards,
Geoff
 
R

rf

Geoff Ball said:
Ahh...

I guess it would've helped to read his post first. ;)

<reads between the lines of the post>

I'll just bet the OP is using a table to contain a nav bar and the cells
contain links. Said OP is getting annoyed that the hover applied to the
links only changes the links, not the entire cell.

The solution here is to add display: block to the links so they fill the
entire table cell. That way it "looks" like the cell has hover properties.
Browser support varies but it's better than using a hover pseudo class on
the td.

Unfortunately we'll probably never find out as the OP _does_ come from aol
:)

Cheers
Richard.
 
H

Half Dolla 2003

I'll just bet the OP is using a table to contain a nav bar and the cells
contain links.

Yes, that's it... and it would appear that there's no legit way of doing this
without putting all the code in every tag. The display:block idea doesn't
appear to make the entire cell light up.
Unfortunately we'll probably never find out as the OP _does_ come from aol
:)

AOL = elite.
 
J

Jacqui or (maybe) Pete

halfdolla2003 said:
Yes, that's it... and it would appear that there's no legit way of doing this
without putting all the code in every tag. The display:block idea doesn't
appear to make the entire cell light up.

IE6 is a bit dim - you have to add 'width:100%' to help the poor old
thing along to the correct conclusion. Here's one I prepared earlier:

http://porjes.com/tablemenu.html
AOL = elite.
That's not how we pronounce it over here :0)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,270
Latest member
TopCryptoTwitterChannels_

Latest Threads

Top