I am trying to achieve a hover effect on a table row and I have the following code on my css.
.datatable tr.row:hover, .datatable tr.altrow:hover {
color: #000;
background-color: #FFFACD;
background-image: url(../Images/bullet.gif);
background-repeat: no-repeat;
}
But I do not see that being applied at all. My questions are
For clarity here is the fiddle http://jsfiddle.net/naveen/UPhRE/
Please don't mind the images inside the css. All is well there.
You are setting backgrounds on the individual table cells (td
), which is rendered on top of the tr
.
If you have two choices:
1) Move all row background styling to the tr
s.
2) Update your CSS to look like this:
.datatable tr.row:hover td, .datatable tr.altrow:hover td {
color: #000;
background-color: #FFFACD;
background-image: url(../Images/bullet.gif);
background-repeat: no-repeat;
}
This will render the color on the row: http://jsfiddle.net/R9YGw/3/
Update: Included update for image on first cell only:
.datatable tr.row:hover td, .datatable tr.altrow:hover td {
color: #000;
background-color: #FFFACD;
}
.datatable tr.row:hover td:first-child, .datatable tr.altrow:hover td:first-child {
background-image: url(../Images/bullet.gif);
background-repeat: no-repeat;
}
The problem you have is that you set a background color on the td elements, which are further down the DOM tree and thus the color of these takes precedence.
If you apply the color to just the row you will see the hover appearing:
.datatable .row
{
background-color: #FFFFFF;
}
.datatable .altrow
{
background-color: #EDF5FF;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With