繁体   English   中英

使用Rails 5和bootstrap-sass gem时,bootstrap glyphicons不出现

[英]Bootstrap glyphicons aren't appearing when using Rails 5 and bootstrap-sass gem

引导程序产生的Glyphicons没有出现在我的网站上。 我去检查了chrome开发工具中的“ Network标签,看到了这样的字体请求:

Request URL:http://localhost:3000/fonts/bootstrap/glyphicons-halflings-regular.woff2
Request Method:GET
Status Code:404 Not Found

所以我抓住了glyphicon字体,并将它们放在app/assets/fonts/bootstrap ,但这是行不通的。 我将fonts/文件夹移到public/然后重试。 Glyphicons起作用了,但这似乎是一种不好的做法。

如何将字体保留在app/assets/fonts并正确加载?

当我写这个问题时,我发现了。

在您的引导程序主题文件中,查找以下几行:

//== Iconography
//
//## Specify custom location and filename of the included Glyphicons icon font. Useful for those including Bootstrap via Bower.

//** Load fonts from this directory.

// [converter] If $bootstrap-sass-asset-helper if used, provide path relative to the assets load path.
// [converter] This is because some asset helpers, such as Sprockets, do not work with file-relative paths.
$icon-font-path: if($bootstrap-sass-asset-helper, "bootstrap/", "../fonts/bootstrap/");

我更改了变量$icon-font-path所以它看起来像这样:

$icon-font-path: if($bootstrap-sass-asset-helper, "bootstrap/", "../assets/fonts/bootstrap/");

注意:所有glyphicon字体文件都存在于app/assets/fonts/bootstrap

我建议您使用: font-awesome-sass

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM