【问题标题】:Icon font from fontello not working with Meteor js来自 fontello 的图标字体不适用于 Meteor js
【发布时间】:2013-06-01 00:49:50
【问题描述】:

我从 fontello 下载了一个自定义图标字体,并打算在我的流星应用程序中使用它。 我尝试了下载包附带的演示,字体显示正常。这是我的CSS:

@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>,不幸的是,当我查看页面时,我看到的就是这一切 任何帮助都会很棒。谢谢

【问题讨论】:

    标签: html css meteor icons fontello


    【解决方案1】:

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

    @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 足够聪明,可以猜出路径。

    【讨论】:

      【解决方案2】:

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

      查看此处的非官方 Meteor 常见问题解答:https://github.com/oortcloud/unofficial-meteor-faq#where-should-i-put-my-files

      public/ #

      或者直接使用 Meteor 文档:http://docs.meteor.com/#structuringyourapp

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

      【讨论】:

        【解决方案3】:

        尝试使用绝对路径:

        @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

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2019-12-20
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2021-03-21
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多