gpt4 book ai didi

ruby-on-rails - 如何在 Rails 4 中使用 @font-face 嵌入字体?

转载 作者:数据小太阳 更新时间:2023-10-29 08:17:29 26 4
gpt4 key购买 nike

标题几乎说明了一切......

我尝试添加 /app/assets/fonts/font.woff 并使用 /app/assets/fonts/font.woff 从我的 css 文件中引用它,但是它似乎不起作用。

有什么想法吗?

最佳答案

事实证明,@JimLim 提到的 Assets 管道在 Rails 4 中的工作方式有点不同。完整文档 here ,但这里是相关的摘录:

2 How to Use the Asset Pipeline

In previous versions of Rails, all assets were located in subdirectories of public such as images, javascripts and stylesheets. With the asset pipeline, the preferred location for these assets is now the app/assets directory. Files in this directory are served by the Sprockets middleware.

Assets can still be placed in the public hierarchy. Any assets under public will be served as static files by the application or web server. You should use app/assets for files that must undergo some pre-processing before they are served.

In production, Rails precompiles these files to public/assets by default. The precompiled copies are then served as static assets by the web server. The files in app/assets are never served directly in production.

所以我最终将我的/fonts 目录移动到/public 相应地调整了我在 @font-face 声明中的路径,一切正常。

关于ruby-on-rails - 如何在 Rails 4 中使用 @font-face 嵌入字体?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18281376/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com