Click here to Skip to main content
15,907,906 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello.. need some help

i have 4 rows, 3 columns. two columns are set to orange, while in the last columns i set a background-color to green. i set background-color hover for a rows to red. also i set same background-color hover to last columns, just trying to make it highlighted when i points a mouse over it anywhere on each rows and columns. i want red color highlights all the rows and columns when a mouse points to any row/column.


<table>

   <tr>
   <td>OrangeA1</td>
   <td>OrangeB1</td>
   <td>GreenC1</td>
   </tr>

   <tr>
   <td>OrangeA2</td>
   <td>OrangeB2</td>
   <td>GreenC2</td>
   </tr>

   <tr>
   <td>OrangeA3</td>
   <td>OrangeB3</td>
   <td>GreenC3</td>
   </tr>

   <tr>
   <td>OrangeA4</td>
   <td>OrangeB4</td>
   <td>GreenC4</td>
   </tr>

</table>

table { 
  width: 300px;
  color: white;
}

tr {
  background-color: orange;
}

td:nth-child(3) {
  background-color: seagreen;
}

/*hover-start*/

tr:hover, td:nth-child(3):hover {
  background-color: red;
}

/*hover-end*/


What I have tried:

this line doesn't work
tr:hover, td:nth-child(3):hover {
  background-color: red;
}
Posted
Updated 1-May-20 21:09pm

1 solution

try this:

CSS
tr:hover td{
  background-color: red;
}
 
Share this answer
 
Comments
Dec Fathani 2-May-20 3:20am    
it works.. thanks alot

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900