我在 ruby on rails 元素中使用 twitter bootstrap 并添加了适当的 gem 等。
一切正常,直到我添加了一个字形图标 - 按照:
<span class="glyphicon glyphicon-user"></span>
现在我得到这个错误:
http://localhost:3000/assets/twitter-bootstrap-static/twitter/fonts/glyphicons-halflings-regular.ttf - HTTP 404.
我已经阅读了关于堆栈溢出的许多其他类似问题,但解决方案似乎不适合我的应用程序。
对于那些感兴趣的人来说,大多数建议的修复都涉及 app/assetts/stylesheets/bootstrap_and_overrides.css.less 这是该文件的当前内容:
@import "twitter/bootstrap/bootstrap";
// Set the correct sprite paths
@iconSpritePath: image-url("twitter/bootstrap/glyphicons-halflings.png");
@iconWhiteSpritePath: image-url("twitter/bootstrap/glyphicons-halflings-white.png");
// Set the Font Awesome (Font Awesome is default. You can disable by commenting below lines)
@fontAwesomeEotPath: font-url("fontawesome-webfont.eot");
@fontAwesomeEotPath_iefix: font-url("fontawesome-webfont.eot?#iefix");
@fontAwesomeWoffPath: font-url("fontawesome-webfont.woff");
@fontAwesomeTtfPath: font-url("fontawesome-webfont.ttf");
@fontAwesomeSvgPath: font-url("fontawesome-webfont.svg#fontawesomeregular");
// Font Awesome
@import "fontawesome/font-awesome";
// Glyphicons
//@import "twitter/bootstrap/glyphicons.less";
// Your custom LESS stylesheets goes here
//
// Since bootstrap was imported above you have access to its mixins which
// you may use and inherit here
//
// If you'd like to override bootstrap's own variables, you can do so here as well
// See http://twitter.github.com/bootstrap/customize.html#variables for their names and documentation
//
// Example:
// @link-color: #ff0000;
也许这个文件中的图标 Sprite 路径是错误的?我不确定它应该是什么?
请帮忙!
最佳答案
我发现了问题。在 ruby on rails 中,默认情况下似乎设置为使用 fontawesome glyphicons 而不是带有 bootstrap 的默认 glyphicons。
因此我只需要使用一个不同的 css 类来使用这个网站:
http://fortawesome.github.io/Font-Awesome/icons/
Fontawesome 绝对比默认的字形更好,所以我现在使用:
<span class="fa fa-users fa-2x"></span>
我的个人图标!
关于css - Ruby on rails twitter bootstrap glyphicons 路径问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28400171/