Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

CSS TR hover in IE for child TD's

Posted on 2009-05-14
5
Medium Priority
?
2,462 Views
Last Modified: 2013-12-08
Hi Experts

Hopefully a very simple solution but I've been scratching my head with this for a couple of hours now!

I am using the code below to try and create a hover effect for an entire row. This seems to work fine in IE8 when the TD tags are transparent but mine aren't and I simply can't work out how to make the TR class override the TD class.

Would prefer not to use javascript at this point but certainly wouldn't dismiss it.

Many thanks
//CSS
.highlight:hover {background-color:#900;}
.tdMid {background-color:#E9E9E9;}
.tdLight {background-color:#F4F4F4;}
 
//HTML
            <tr class="highlight">
              <td align="center" class="tdMid">Data 1</td>
              <td align="center" class="tdLight">Data 2</td>
              <td align="center" class="tdMid">Data 3</td>
              <td align="center" class="tdLight">Data 4</td>
              <td align="center" class="tdLight">Data 5</td>
            </tr>

Open in new window

0
Comment
Question by:sirnutty1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 16

Accepted Solution

by:
jessc7 earned 2000 total points
ID: 24388033
Try adding the following rule to your CSS. This will cause all of the TD's under the :hover to temporarily be transparent and let the background-color of the TR come through.
.highlight:hover td {background-color:transparent;}

Open in new window

0
 

Author Comment

by:sirnutty1
ID: 24388444
Many thanks jessc7

I have added the suggested line which is getting closer but the underlying TR background-colour is always white now!

Feeling very thick today!! Any ideas
.tdMid {background-color:#E9E9E9;}
.tdLight {background-color:#F4F4F4;}
.highlight:hover {background-color:#900;}
.highlight:hover td {background-color:transparent;}

Open in new window

0
 

Author Comment

by:sirnutty1
ID: 24388534
Just managed to work it out thanks to your original post.

Sincere thanks, headache averted.
0
 

Author Comment

by:sirnutty1
ID: 24388538

.tdMid {background-color:#E9E9E9;}
.tdLight {background-color:#F4F4F4;}
.highlight:hover, .highlight:hover td {background-color:#FFDFDF;}

Open in new window

0
 
LVL 16

Expert Comment

by:jessc7
ID: 24388566
I know what those days are like!

I'm not exactly sure. When I view it locally, everything works fine. I've included my test HTML as well as a couple screenshots showing the off state and the hover state.

What DTD are you using?
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Test</title>
<style>
.tdMid {background-color:#E9E9E9;}
.tdLight {background-color:#F4F4F4;}
.highlight:hover {background-color:#900;}
.highlight:hover td {background-color:transparent;}
</style>
</head>
<body>
 
<table>
<tr class="highlight">
<td align="center" class="tdMid">Data 1</td>
<td align="center" class="tdLight">Data 2</td>
<td align="center" class="tdMid">Data 3</td>
<td align="center" class="tdLight">Data 4</td>
<td align="center" class="tdLight">Data 5</td>
</tr>
</table>
 
</body>
</html>

Open in new window

off.png
hover.png
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
Ever visit a website where you spotted a really cool looking Font, yet couldn't figure out which font family it belonged to, or how to get a copy of it for your own use? This article explains the process of doing exactly that, as well as showing how…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
How to create a custom search shortcut to site-search Experts Exchange using Google in the Firefox browser. This eliminates the need to type out site:experts-exchange.com whenever you want to search the site. Launch your Bookmark Menu: Press 'Ctrl +…

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question