出于某种原因,我必须在<a>标签中包装我的图标。 有任何可能的方法来改变字体的颜色,令人敬畏的图标为黑色? 或者只要它被包装在<a>标签中就不可能了?字体很棒应该是字体而不是图像,对吧?
<a href="/users/edit"><i class="icon-cog"></i> Edit profile</a>
出于某种原因,我必须在<a>标签中包装我的图标。 有任何可能的方法来改变字体的颜色,令人敬畏的图标为黑色? 或者只要它被包装在<a>标签中就不可能了?字体很棒应该是字体而不是图像,对吧?
<a href="/users/edit"><i class="icon-cog"></i> Edit profile</a>
当前回答
对我来说,唯一有效的是内联css +覆盖
<i class="fas fa-ellipsis-v fa-2x" style="color:red !important"></i>
其他回答
我添加了一个样式,然后是你选择的颜色,确保它是粗体
使用color属性更改目标元素的颜色,如下所示:
.icon-cog { // selector of your element
color: black;
}
或者在最新版本的font-awesome中,你可以选择填充或不填充图标
试试这个:
<i class="icon-cog text-red">
<i class="icon-cog text-blue">
<i class="icon-cog text-yellow">
你可以通过使用css color属性改变前景色来改变fontawesome图标的颜色。以下是一些例子:
<i class="fa fa-cog" style="color:white">
这也支持svgs
<style>
.fa-cog{
color:white;
}
</style>
<style>
.parent svg, .parent i{
color:white
}
</style>
<div class="parent">
<i class="fa fa-cog" style="color:white">
</div>
对我来说,唯一有效的是内联css +覆盖
<i class="fas fa-ellipsis-v fa-2x" style="color:red !important"></i>