gpt4 book ai didi

css - 在我的 Rails 应用程序中找不到一些字体文件

转载 作者:行者123 更新时间:2023-11-28 06:22:59 25 4
gpt4 key购买 nike

Rails 应用,部署到 digitalocean:找不到字体文件,“entypo.ttf”和“entypo.woff”正在生产

字体文件路径:app/assets/fonts

字体的 CSS 代码:

@font-face {
font-family: 'entypo';
src: url('/assets/entypo.eot?71205724');
src: url('/assets/entypo.eot?71205724#iefix') format('embedded-opentype'),
url('/assets/entypo.woff?71205724') format('woff'),
url('/assets/entypo.ttf?71205724') format('truetype'),
url('/assets/entypo.svg?71205724#entypo') format('svg');
font-weight: normal;
font-style: normal;
}

在开发环境中一切正常。

有什么解决办法吗?

最佳答案

您必须使用 asset-pathasset-url 而不是尝试直接链接到文件。您的生产环境可能会为您对文件进行指纹识别。

@font-face {
font-family: 'entypo';
src: asset-url('fonts/entypo.eot?71205724');
src: asset-url('fonts/entypo.eot?71205724#iefix') format('embedded-opentype'),
asset-url('fonts/entypo.woff?71205724') format('woff'),
asset-url('fonts/entypo.ttf?71205724') format('truetype'),
asset-url('fonts/entypo.svg?71205724#entypo') format('svg');
font-weight: normal;
font-style: normal;
}

确保您阅读了 the asset pipeline !特别是关于 CSS and SASS 的小节

关于css - 在我的 Rails 应用程序中找不到一些字体文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35460020/

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