gpt4 book ai didi

html - 如何更改 Font Awesome 图标的颜色

转载 作者:太空狗 更新时间:2023-10-29 14:54:58 25 4
gpt4 key购买 nike

我有一个使用 ng-repeat 生成的 table

当用户选择表格行时,我可以应用以突出显示 table 行并应用特定类。

问题是我无法更改 row 中的图标,突出显示的 background-color 行也是 blue 和文本更改为 white 但图标保持蓝色。

CSS

.selected{
background-color:#004b89;
color:white;
font-weight:bold;
}

HTML

<tr ng-repeat="item in vm.items ng-class="{'selected':$index == vm.selectedRow}" class="table-striped" ng-click="vm.setClickedRow($index)">
<td><a tooltip-placement="top"><i class="fa fa-pencil fa-2x link-icon"></i> </a>
<td><a tooltip-placement="top"><i class="fa fa-trash fa-2x link-icon"></i></a>
</tr>

最佳答案

选择要更改颜色的 font-awesome 类,因为这可能是 CSS 特异性问题。

.not-selected .fa-pencil {
color: red
}
.not-selected .fa-trash {
color: green
}
.selected {
background-color: #004b89;
color: white;
font-weight: bold;
}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet" />
<table>
<tr class="not-selected">
<td><a tooltip-placement="top"><i class="fa fa-pencil fa-2x link-icon"></i></a>
<td><a tooltip-placement="top"><i class="fa fa-trash fa-2x link-icon"></i></a>
</tr>
<tr class="selected">
<td><a tooltip-placement="top"><i class="fa fa-pencil fa-2x link-icon"></i></a>
<td><a tooltip-placement="top"><i class="fa fa-trash fa-2x link-icon"></i></a>
</tr>
</table>

关于html - 如何更改 Font Awesome 图标的颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37379443/

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