图标字体(@ font-face)不在本地主机上呈现 [英] Icon font (@font-face) not rendering on localhost
问题描述
我有在我的locahost上工作的 font-awesome 图标字体,以及我的mysite.com都是nginx服务器。奇怪的是,当我试图实现从 Glyphicons 设置的类似图标字体时,图标只会在mysite.com上呈现,但
I have the font-awesome icon-font working on my locahost as well as my mysite.com which are both nginx servers. Strangely, when I tried to implement a similar icon font set from Glyphicons the icons only render on mysite.com but not on my localhost.
这些图标通常与我的本地主机看起来不同:
Here's what the icons look like normally vs. how they look on my localhost:
正常:
:
在我的localhost上不能识别 font-family:'Glyphicons'
属性,因为只需注释掉字体
CSS属性在mysite.com上重新创建红框外观:
The problem is that the font-family: 'Glyphicons'
attribute is not being recognized on my localhost because simply commenting out the font
CSS property on mysite.com re-creates the red box appearance:
.glyphicons i::before {
position: absolute;
left: 0;
top: 0;
font: 24px/1em 'Glyphicons'; // commenting out this line re-creates the red box pattern
font-style: normal;
color: #1D1D1B;
color: red;
}
推荐答案
@David(见上面的注释)帮助我回答我自己的问题。该问题是文件权限问题。我刚刚添加了Glyphicons文件夹到我的localhost应用程序文件夹(即/ html),它没有正确的权限。只需在命令行中输入以下内容即可解决问题:
I'd like to thank @David (see comments above) for helping me answer my own question. The issue was a file permission issue. I had just added the Glyphicons folder to my localhost application folder (i.e., /html) and it didn't have the right permissions. Simply typing the following in the command line solved the problem:
html TimPeterson$ chmod -R 777 assets/glyphicons/ /*this command allows access to all (777) for all files and folders (-R) within the glyphicons folder*/
所以它不是CSS,MIME类型,或任何其他与Nginx一样,我最初想的。
So it wasn't CSS, mime-types, or anything else to do with Nginx as I had originally thought.
这篇关于图标字体(@ font-face)不在本地主机上呈现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!