Home >Web Front-end >CSS Tutorial >How to achieve the discoloration effect of mouse click table in css

How to achieve the discoloration effect of mouse click table in css

WBOY
WBOYOriginal
2021-11-26 11:49:426175browse

在css中,可以利用“:active”选择器和background属性实现鼠标点击表格变色效果,语法为“表格元素:active{background:颜色值;}”。

How to achieve the discoloration effect of mouse click table in css

本教程操作环境:windows7系统、CSS3&&HTML5版、Dell G3电脑。

css怎样实现鼠标点击表格变色效果

在css中可以利用“:active”选择器和background属性来实现鼠标点击表格变色效果。

:active”选择器用于选中鼠标点击元素时的状态,background属性用于设置元素的背景颜色。

下面我们通过示例来看一下怎样实现鼠标点击表格变色,示例如下:

<html>
<body>
<style>
.biaoge:active{
background:red;
}
</style>
<table border="1" class="biaoge">
  <tr>
    <th>Month</th>
    <th>Savings</th>
  </tr>
  <tr>
    <td>January</td>
    <td>$100</td>
  </tr>
</table>
</body>
</html>

输出结果:

How to achieve the discoloration effect of mouse click table in css

(学习视频分享:css视频教程

The above is the detailed content of How to achieve the discoloration effect of mouse click table in css. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn