首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >来自fontello的图标字体不适用于Meteor js

来自fontello的图标字体不适用于Meteor js
EN

Stack Overflow用户
提问于 2013-06-05 18:47:26
回答 3查看 4.4K关注 0票数 2

我已经从fontello下载了一个自定义图标字体,并打算在我的meteor应用中使用它。我尝试了下载的软件包附带的演示,字体显示良好。这是我的css:

代码语言:javascript
复制
@font-face {
 font-family: 'fontello';
 src: url('fonts/fontello.eot?98991264');
 src: url('fonts/fontello.eot?98991264#iefix') format('embedded-opentype'),
   url('fonts/fontello.woff?98991264') format('woff'),
   url('fonts/fontello.ttf?98991264') format('truetype'),
   url('fonts/fontello.svg?98991264#fontello') format('svg');
font-weight: normal;
font-style: normal;
}

[class^="icon-"]:before, [class*=" icon-"]:before {
 font-family: "fontello";
 font-style: normal;
 font-weight: normal;
 speak: none;
 display: inline-block;
 text-decoration: inherit;
 width: 1em;
 margin-right: .2em;
 text-align: center;

 /* For safety - reset parent styles, that can break glyph codes*/
 font-variant: normal;
 text-transform: none;

 /* fix buttons height, for twitter bootstrap */
 line-height: 1em;

}

.icon-twitter:before { content: '\e805'; } /* '' */
.icon-github-circled:before { content: '\e804'; } /* '' */
.icon-pencil:before { content: '\e801'; } /* '' */
.icon-cancel:before { content: '\e802'; } /* '' */
.icon-chat:before { content: '\e800'; } /* '' */

我的文件夹结构是这样的/client/css/styles.css和字体的/client/css/fonts/

在我的html中,我添加了这个标记<i class="icon-twitter"></i>,不幸的是,当我查看这个页面时,我看到的就是这些。

任何帮助都是最好的。谢谢

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2013-06-05 19:28:02

如果你想在your.domain.com/fonts/font_name.x中引用你的字体,你应该把你的fonts目录移到一个标有public的目录下。然后,您可以使用路径/fonts/font_name.x访问它们。

看看这里的非官方流星常见问题解答:https://github.com/oortcloud/unofficial-meteor-faq#where-should-i-put-my-files

public/ # <-直接提供的静态文件,如图片。

或者直接访问流星文档:http://docs.meteor.com/#structuringyourapp

最后,流星服务器将提供公共目录下的任何文件,就像在Rails或Django项目中一样。这是存放图片、favicon.ico、robots.txt和其他任何东西的地方。

票数 6
EN

Stack Overflow用户

发布于 2013-06-05 19:27:11

尝试使用绝对路径:

代码语言:javascript
复制
@font-face {
 font-family: 'fontello';
 src: url('/client/css/fonts/fontello.eot?98991264');
 src: url('/client/css/fonts/fonts/fontello.eot?98991264#iefix') format('embedded-opentype'),
   url('/client/css/fonts/fontello.woff?98991264') format('woff'),
   url('/client/css/fonts/fontello.ttf?98991264') format('truetype'),
   url('/client/css/fonts/fontello.svg?98991264#fontello') format('svg');
font-weight: normal;
font-style: normal;
}

此外,在/public中存储字体可能会更好,因为在生产模式下,/client不再起作用,你会再次得到那些方块&你可以使用/fonts/ (映射到/public/fonts)。

票数 0
EN

Stack Overflow用户

发布于 2014-01-24 04:05:23

我也有同样的问题,我解决的方法是使用这些绝对路径:

代码语言:javascript
复制
@font-face {
    font-family: 'icomoon';
    src:url('/fonts/icomoon.eot');
    src:url('/fonts/icomoon.eot?#iefix') format('embedded-opentype'),
      url('/fonts/icomoon.woff') format('woff'),
      url('/fonts/icomoon.ttf') format('truetype'),
      url('/fonts/icomoon.svg#icomoon') format('svg');
    font-weight: normal;
    font-style: normal;
 }

直接在public/fonts/目录上。我猜MeteorJS足够聪明,可以猜测路径。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16937918

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档