如何更改字体真棒图标的颜色

时间:2016-05-22 20:41:27

标签: html css angularjs font-awesome

我使用table生成ng-repeat

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

问题是我在row更改图标时遇到问题,突出显示的行background-colorblue,文字更改为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>

2 个答案:

答案 0 :(得分:8)

选择要更改颜色的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>

答案 1 :(得分:0)

很容易。我在下面给出的代码是l =有点酷,颜色不断变化,就像魔法一样。使用它和c MAAGIC ..

.fa
{
    color:black;

    animation: colorchange1 50s;
    -webkit-animation: colorchange1 50s
}

@keyframes colorchange1
{
0%   {color: green;}
15%  {color: orange;}
30%  {color:purple;}
45%  {color: #e74c3c;}
60% {color: violet;}
75% {color: indigo;}
90% {color: blue;}
100% {color: black;}
}

@-webkit-keyframes colorchange1 /* Safari and Chrome - necessary duplicate */
{
    0%   {color: green;}
    15%  {color: orange;}
    30%  {color:purple;}
    45%  {color: #e74c3c;}
    60% {color: violet;}
    75% {color: indigo;}
    90% {color: blue;}
    100% {color: black;}
}

希望它可以理解。