我的指南针目录如下所示:
root_of_directory
sass
screen.scss
stylesheets
fonts
goudysto.ttf
screen.css
然后mixin for font-face看起来像这样:
@include font-face("goudysto", font-files("goudysto.ttf", "truetype"));
控制台中的输出显示:
GET file:///fonts/goudysto.ttf net::ERR_FILE_NOT_FOUND
这是输出的css
@font-face {
font-family: "goudysto";
src: url('/fonts/goudysto.ttf') format('truetype');
}
谁能告诉我为什么会这样?
* UPDATE - config.rb *
require 'compass/import-once/activate'
# Require any additional compass plugins here.
# Set this to the root of your project when deployed:
http_path = "/"
css_dir = "stylesheets"
sass_dir = "sass"
images_dir = "images"
javascripts_dir = "javascripts"
fonts_dir = "stylesheets/fonts"
# You can select your preferred output style here (can be overridden via the command line):
# output_style = :expanded or :nested or :compact or :compressed
# To enable relative paths to assets via compass helper functions. Uncomment:
# relative_assets = true
# To disable debugging comments that display the original location of your selectors. Uncomment:
# line_comments = false
# If you prefer the indented syntax, you might want to regenerate this
# project again passing --syntax sass, or you can uncomment this:
# preferred_syntax = :sass
# and then run:
# sass-convert -R --from scss --to sass sass scss && rm -rf sass && mv scss sass
答案 0 :(得分:0)
在config.rb中设置fonts_dir,如下所示:
fonts_dir = "stylesheets/fonts"
编辑:另外,如评论中所述,请务必取消注释# relative_assets = true
并使用config.rb中的相对路径...