Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS on hover effect on a <td> does not wok properly if <td> has multiple <div>s inside it

I have a table column with multiple divs inside it to fit in an icon, title and description text. Also, on mouse over, I need to provide a highlight /overlay effect that highlights all of the column including the divs image, title and description text.

Here is the HTML

 <td>
   <div style="display:inline-block; border:1px solid red">left</div>
    <div style="display:inline-block">
    <div style="display:inline-block; border:1px solid blue">top left</div>
    <div style="display:inline-block; border:1px solid green">top right</div>
    <div>bottom </div>  
   </div>
 </td>

When I use a simple CSS effect to change the background of the column as below, the effect shows up only on individual divs but not the entire table column. I want that if any of the divs get a mouse over, all of the column should be highlighted.

CSS code

#MyTable td :hover {
background: #cccccc;
}
like image 248
user1006072 Avatar asked Nov 20 '25 17:11

user1006072


2 Answers

you have an extra space before :hover : try with

#MyTable td:hover { 
   background-color: #ccc;
}
like image 193
Fabrizio Calderan Avatar answered Nov 23 '25 10:11

Fabrizio Calderan


#MyTable td:hover {
  background: #cccccc;
}

i think problem is you should use ":" right after "td"

like image 36
tcgumus Avatar answered Nov 23 '25 08:11

tcgumus



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!