如何在我的CSS中使用fontello中的图标?

时间:2013-10-04 13:42:28

标签: html css pseudo-element icon-fonts fontello

我一直在使用entypo(从entypo.com下载),并显示如下图标:

.icon:before {
  display: inline-block;
  font-family: 'Entypo';
  text-decoration: none;
  speak: none;
}

.email:before {
  content: "\2709";
}

非常标准。但是,当你从entypo.com下载它时暗示已经关闭,我已经转而从fontello下载了它。只是现在我的CSS内容代码不再起作用了。

我可以在演示中看到fontello使用这样的跨度来调用html中的图标:

<span class="i-code">0xe829</span>

但这对我来说似乎很难看。我想从css中做到这一点,但是如何才能找出我的CSS中要放入哪种代码?

1 个答案:

答案 0 :(得分:19)

好的,所以我发现你要做的就是不使用fontello上提到的代码:

U+E84D
U+E854

但是将这些重写为:

\E84D
\E854

(因此删除“U +”并将其替换为“\”)

像这样使用它们:

content: "\E84D";

编辑:

因此,根据要求,您将使用的完整CSS语法是:

.icon:before {
  display: inline-block;
  font-family: 'Entypo';
  text-decoration: none;
  speak: none;
}

.email:before {
  content: "\E84D";
}

结合以下HTML:

<a href="#" class="icon email">Mail me</a>