/    Sign up×
Community /Pin to ProfileBookmark

cell bgcolor change on a:hover

I want to change the background color of a cell when the mouse is put over the cell. I have found that background-color: #000000 will change only the background of the text in the cell. I want the entire cell background to change color, not the background of just the text.

Please help.

-cmotor

to post a comment
CSS

4 Comments(s)

Copy linkTweet thisAlerts:
@ray326Nov 08.2004 — Define "cell".
Copy linkTweet thisAlerts:
@HaganeNoKokoroNov 08.2004 — You'll have to be a little more clear. From the a:hover in the title of your post, it sounds like you're trying to get a table cell to change color when you mouse over a link inside the cell. Why not just use td:hover (aside from it doesn't work in IE without a weensy javascript workaround)

your css could be something like:td.hov {
width:200px;
height:200px;
background-color:#666666;
behavior:url(IEHover.htc);
}

td.hov:hover, td.hovhover {
/*same style as above, but different color*/
width:200px;
height:200px;
background-color:#662299;
behavior:url(IEHover.htc);
}
and IEHover.htc looks like this<public:attach event="onmouseover" onevent="hoverOn()" />
<public:attach event="onmouseout" onevent="hoverOff()" />
<script type="text/javascript">
function hoverOn() {
element.className+= "hover";
}

function hoverOff() {
element.className=element.className.replace(/hover/g, "");
}
</script>
By the way, I heard of this approach of working around IE's CSS limitations in Vladdy's pure CSS menu.
Copy linkTweet thisAlerts:
@BonRougeNov 08.2004 — I think this :

[B]* html td a {width: 100%;}[/B]

is the key.

Check it out

[CODE]
<style type="text/css">
td a {
text-decoration:none;
background-color:red;
color:navy;
display:block;
}

* html td a {
width: 100%;
}

td a:hover {
background-color:navy;
color:red;
}


</style>

</head>
<body>

<table>
<tr>
<td><a href="">This is the first line</a></td>
<td><a href="">This is the second line</a></td>
<td><a href="">This is the third line</a></td>
<td ><a href="">This is the fourth line</a></td>
</tr>
<tr>
<td><a href="">This is the fifth line</a></td>
<td><a href="">This is the sixth line</a></td>
<td><a href="">This is the seventh line</a></td>
<td><a href="">This is the eighth line</a></td>
</tr>
</table>

</body> [/CODE]
Copy linkTweet thisAlerts:
@JohnWorfinDec 01.2004 — tag for good info
×

Success!

Help @cmotor spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...