将Font Awesome图标添加到类 [英] Add Font Awesome Icon To Class

查看:85
本文介绍了将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".

这篇关于将Font Awesome图标添加到类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆