首页htmltdHTML Element Style - 如何当悬停时更改表格单元格背景颜色

HTML Element Style - 如何当悬停时更改表格单元格背景颜色

我们想知道如何当悬停时更改表格单元格背景颜色。

<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
tr {
  color: #222;
  background-color: #f0f0f0;
}

tr:hover {
  color: #fff;
  background-color: #0080ff;
}
</style>
</head>
<body>
  <table>
    <tr>
      <td>Sample</td>
      <td>Text</td>
    </tr>
  </table>
</body>
</html>