html - 更改文本和背景颜色 CSS / HTML
问题描述
我正在使用此类来更改效果很好的背景和文本颜色。
#cellType1 {
width: 10%;
height: 83px;
vertical-align: middle;
background-image: url("Index.html")
}
#cellType1:hover {
color: white;
background-color: #6EBA37;
transition:0.6s;
}
...
<td id="cellType1" class="auto-style21" style="width: 10%">
<a class="auto-style24" href="ContactUs.html">
<span class="auto-style37">Contact Us </span></a></td>
auto-style21 工作正常,但是当我将文本更改为超链接时,我无法让文本更改颜色。
我知道这与样式有关,但我无法弄清楚当单元格悬停时如何控制超链接的文本。甚至在将鼠标悬停在文本上时更改文本的颜色也可以。
我更希望在鼠标进入单元格时更改文本。
解决方案
您需要直接或间接定位 A,而不是单元格的悬停,以使样式应用于链接。
如果您希望链接根据单元格本身的悬停而更改,您可以使用以下内容:
更改这部分代码:
#cellType1:hover {
color: white;
background-color: #6EBA37;
transition:0.6s;
}
对此:
#cellType1:hover {
color: white;
background-color: #6EBA37;
transition:0.6s;
}
#cellType1:hover a {
color: white;
transition:0.6s;
}
推荐阅读
- arrays - 返回由几个 SUM.PRODUCT 公式组成的数组中 MAX 值的位置?
- java - 如何按值对 HashMap 进行排序但保持重复的顺序?
- google-apps-script - 如何在 Google Apps 脚本/表格中的 IF 语句中比较当前编辑时间与指定条件时间?
- javascript - 如何在反应导航中导航和传递同一组件的道具?
- reactjs - 第三方 html 标签的 React 参考
- python - 如何在pyautogui中按Windows + s?如何通过python脚本一次最小化所有打开的窗口?
- html - 如何在 div 的标题属性中显示解释的 HTML,取自 Angular 字符串变量?
- javascript - Javascript插件公共方法不起作用
- laravel - 模型更新观察者上的 Laravel 关系为空
- spring-restdocs - Spring rest docs request url 显示路径参数的值而不是参数名称