簡體   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