简体   繁体   English

真棒字体图标在更改字体后消失

[英]Font-awesome Icon disappearing on change of font

I'm trying to incorporate font-awesome icons in my webpage, and it all works fine, until I change to my font of choice, Exo 2 , and the icons show up as a bordered square. 我正在尝试在网页中加入超棒的图标,并且一切正常,直到更改为我选择的字体Exo 2为止,并且这些图标显示为带边框的正方形。 It works fine with other fonts, but for some reason this won't work. 它可以与其他字体一起正常工作,但是由于某些原因,它将无法正常工作。

I have included the font-awesome stylesheet, and the google fonts stylesheet. 我已经包括了真棒字体样式表和google字体样式表。

If anyone could point me to what I'm doing wrong, would be appreciated! 如果有人可以指出我在做什么,那将不胜感激!

fontawesome is font icons and Exo 2 is font and not "font icons" fontawesome是字体图标,而Exo 2是字体,而不是“字体图标”

to work fontawesome u must apply 工作字体很棒你必须申请

font-family: FontAwesome;

and if u change it to something else here i think "Exo 2" 如果您将其更改为其他内容,我会认为是“ Exo 2”

font-family: Exo 2;

it wont work and will disply u square 它不会工作,并且会显示您的方块

This issue with font-awesome could be due to setting other font to the icon. 字体超赞的问题可能是由于将其他字体设置为图标造成的。 Please see this fiddle 请看这个小提琴

 .parent1, .parent1 > i{ font-family: 'Open Sans', sans-serif; } .parent2{ font-family: 'Open Sans', sans-serif; } 
 <script src="https://use.fontawesome.com/a30dc5ca39.js"></script> <div class="parent1"> <i class="fa fa-times"></i>This won't work </div> <div class="parent2"> <i class="fa fa-times"></i>This works </div> 

If you set the font to the child element ie the <i> element, then font-awesome won't be rendered as you expect. 如果您将字体设置为子元素(即<i>元素),那么字体真棒将无法按预期呈现。

In the second example I only set different font to the parent, but not the icon, and it works as expected 在第二个示例中,我只为父级设置了不同的字体,但没有为图标设置字体,它可以按预期工作

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM