CSS将鼠标悬停在表格上时更改表格中特定单元格的背景颜色 [英] CSS Changing background colour of specific cell in table when hovering over it

查看:64
本文介绍了CSS将鼠标悬停在表格上时更改表格中特定单元格的背景颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含三列的表.我希望能够将鼠标悬停在第三列时仅更改其格式.

I have a table with three columns. I want to be able to change the formatting of only the third column when I hover over it.

我希望能够合并

td:nth-​​child(3){background-color:#ddd;}

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

td:hover {background-color:#ddd;}

td:hover {background-color: #ddd;}

我该怎么做?

推荐答案

我认为这就是您所追求的.

I think this is what you are after.

td:hover:nth-child(1) {background-color: #f5f5f5;}
td:hover:nth-child(2) {background-color: #ff0000;}
td:hover:nth-child(3) {background-color: #ddd;}

<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tbody>
    <tr>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
  </tbody>
</table>

欢呼

这篇关于CSS将鼠标悬停在表格上时更改表格中特定单元格的背景颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆