将Font Awesome图标添加到类
问题描述:
有人知道如何在其自己的班级中添加特定的字体超赞图标吗?
Does anyone know how to add a specific font awesome icon to it's own class?
例如,我正在使用此图标:
For example, I'm using this icon:
<i class="fa fa-home" aria-hidden="true"></i>
并添加:
.fa-home{
background: #ff0019;
padding: 5.2px 6.5px 8.5px 6.5px;
border-radius: 50%;
}
.fa-home:hover{
background: #333;
}
.fa-home:before {
color:#FFFFFF;
}
但是,我想在网站的不同区域使用.fa-home
However, i want to use .fa-home in different areas of my website without that specific style.
有什么想法吗?
答
添加一个您要设置样式的特定字体真棒图标的ID。
Add an id to that particular font awesome icon that you want to style.
<i class="fa fa-home" id="edit" aria-hidden="true"></i>
然后像这样更改css-
And then change the css like this-
#edit.fa-home{
background: #ff0019;
padding: 5.2px 6.5px 8.5px 6.5px;
border-radius: 50%;
}
#edit.fa-home:hover{
background: #333;
}
#edit.fa-home:before {
color:#FFFFFF;
}
分配此ID仅会更改其标签中包含该ID的图标。这种样式将不会应用于没有id edit的图标。
Assigning this id will only change those icons that contain it in their tags. This style will not be applied to the icons without id "edit".