gpt4 book ai didi

html - 在悬停时突出显示一行,如果没有 !important 则不起作用

转载 作者:行者123 更新时间:2023-11-28 16:06:19 25 4
gpt4 key购买 nike

这是我的 html 文件中的表格。我正在尝试悬停效果,但如果没有 !important,它就无法工作。

<tr ng-repeat="case in lastten" ng-click="setSelected(case.BuildName)" ng-class="{selected: case.Name === idSelectedVote}">
<td colspan="1">{{case.Name}}</td>
<td colspan="1">{{case.Total}}</td>
<td colspan="1">{{case.Passed}}</td>
<td colspan="1">{{case.Failed}}</td>
</tr>

css- 如果我删除 !important 。它不会工作。

table {
width:100%;
table-layout: fixed;
}

table tr:nth-child(even) td {
background: #f3f7fb;
}

table tr:nth-child(odd) td {
background: #ffffff;
}

tr:hover td {
background: #eee !important;
}

最佳答案

您正在尝试使用两个不同的选择器更改 td 的背景颜色。 table tr:nth-child(even) tdtr:hover td 具有更高的优先级。设置 tr 的交替背景色,悬停时可以设置 td 的背景色。

或者,您可以使用以下选择器来增加悬停选择器的优先级

tr:nth-child(n):hover td {
background: #eee;
}

table {
width:100%;
table-layout: fixed;

}

table tr:nth-child(even){
background: #f3f7fb;
}

table tr:nth-child(odd) {
background: #ffffff;
}

tr:hover td {
background: #eee;
}
<table><tr ng-repeat="case in lastten" ng-click="setSelected(case.BuildName)" ng-class="{selected: case.Name === idSelectedVote}">

<td colspan="1">{{case.Name}}</td>
<td colspan="1">{{case.Total}}</td>
<td colspan="1">{{case.Passed}}</td>
<td colspan="1">{{case.Failed}}</td>


</tr>
<tr ng-repeat="case in lastten" ng-click="setSelected(case.BuildName)" ng-class="{selected: case.Name === idSelectedVote}">

<td colspan="1">{{case.Name}}</td>
<td colspan="1">{{case.Total}}</td>
<td colspan="1">{{case.Passed}}</td>
<td colspan="1">{{case.Failed}}</td>


</tr>
</table>

关于html - 在悬停时突出显示一行,如果没有 !important 则不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39160330/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com