html - 如何更改文本字体颜色,同时将鼠标悬停在 a 或 的任何部分?
问题描述
我有一张没有背景的表格,我希望<td>
整个表格<tr>
在悬停时更改背景颜色和字体颜色。我知道如何更改 Hover 上的背景颜色和文本颜色
tr:hover {
background-color: #ddd;
color: black;
}
但是,如果我将鼠标悬停在实际文本上,那只会改变文本颜色,如果我将鼠标悬停在<td>
/的任何部分上,我想同时更改文本和背景颜色,<tr>
而不一定是文本本身。
解决方案
我在网上找到了这个,它可以帮助你:
<style style="text/css">
.hoverTable{
width:100%;
border-collapse: collapse;
}
.hoverTable td{
padding: 7px;
border: #444fa6 1px solid;
}
/* Define the default color for all the table rows */
.hoverTable tr{
background-color: #6b76d1;
}
/* Define the hover highlight color for the table row */
.hoverTable tr:hover {
background-color: #9aa3ed;
color: #a456ba;
}
</style>
<table class="hoverTable">
<tr>
<td>Text 1A</td>
<td>Text 1B</td>
<td>Text 1C</td>
</tr>
<tr>
<td>Text 2A</td>
<td>Text 2B</td>
<td>Text 2C</td>
</tr>
<tr>
<td>Text 3A</td>
<td>Text 3B</td>
<td>Text 3C</td>
</tr>
</table>
推荐阅读
- python - Python,写csv单行多列
- python - 使用阈值图像改变实际图像中的亮度值
- rust - 如何使用 Serde 解析具有多种不同类型的 YAML 文件?
- html - 1fr 网格单元扩展超过 100%
- sql-server - 删除多边形外部的几何数据
- jquery - 克隆一个 HTML 块并将其附加到另一个 div
- dll - 当符号存在时,为什么我会看到符号链接错误消息?
- c# - 在包装 C# .Net DLL 的 C++ 包装器中将 System::String^ 转换为 wchar_t
- docusignapi - 如何让 Docusign 只读复选框选项卡不呈现损坏
- mongodb - 同时对 MongoDB 中的两个字段进行排序