来自bootstrap的Glyphicons没有出现在我的网站上。我去检查chrome dev工具中的S.vertices = [S.vertices;V];
S.faces = [S.faces; Fx; Vx]; % oops... you probably don't want the old faces in there. they're being replaced.
选项卡,并看到这样的字体请求:
Network
所以我抓住glyphicon字体并将它们放在Request URL:http://localhost:3000/fonts/bootstrap/glyphicons-halflings-regular.woff2
Request Method:GET
Status Code:404 Not Found
中,但这不起作用。我将app/assets/fonts/bootstrap
文件夹移至fonts/
并再次尝试。 Glyphicons有效,但这似乎是不好的做法。
如何将字体保留在public/
中并让它们正确加载?
答案 0 :(得分:0)
当我写这个问题时,我想出来了。
在您的bootstrap主题文件中,查找以下行:
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
注意:所有glyphicon字体文件都存在于$icon-font-path: if($bootstrap-sass-asset-helper, "bootstrap/", "../assets/fonts/bootstrap/");
答案 1 :(得分:0)
我建议您使用:font-awesome-sass