热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

当包含web字体时,SASS语法错误-SASSSyntaxErrorwhenincludingwebfont

WhenItrytouserakeassets:precompileRAILS_ENVproductionitthrowsthiserror:当我尝试使用rake资产:pre

When I try to use rake assets:precompile RAILS_ENV=production it throws this error:

当我尝试使用rake资产:precompile RAILS_ENV=生产时,它会抛出这个错误:

Sass::SyntaxError: Invalid CSS after "...awesome-webfont": expected ")", was ".woff);"

This is my style.css file:

这是我的风格。css文件:

@font-face {
    font-family:FontAwesome;
    src:font-image-url(fontawesome-webfont.woff);
}

If I comment the line src:font-image-url(fontawesome-webfont.woff); this error appears

如果我注释行src:font-image-url(fontawesome-webfont.woff);这个错误出现

Sass::SyntaxError: Invalid CSS after "...:image-url(ban2": expected ")", was ".jpg);"

I am using gem "font-awesome-rails" with rails 4.2.4 .

我正在使用gem“font-awesome-rails”和rails 4.2.4。

1 个解决方案

#1


3  

Firstly, you'll need to wrap your URL in quotation marks.

首先,您需要用引号将URL包装起来。

Secondly, SASS does not have a URL helper font-image-url. You're maybe looking for font-url, which does the following:

其次,SASS没有URL帮助器font-image-url。你可能在寻找font-url,它的功能如下:

Generates a path to an asset found relative to the project's font directory.

生成相对于项目的字体目录找到的资产的路径。

Applying the above, you should have something like:

应用上述方法,您应该具有以下内容:

@font-face {
    font-family: "FontAwesome";
    src: font-url("fontawesome-webfont.woff");
}

The second error seems to come from not wrapping a URL value in quotation marks a well.

第二个错误似乎来自于没有在引号中包装URL值。


推荐阅读
author-avatar
心動寶貝r
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有