简体   繁体   中英

Ruby on rails twitter bootstrap glyphicons path problems

I am using twitter bootstrap with ruby on rails project having added the appropriate gems etc.

Everything was working perfectly until I added a glyph icon - as per :

<span class="glyphicon glyphicon-user"></span>

Now I get this error:

http://localhost:3000/assets/twitter-bootstrap-static/twitter/fonts/glyphicons-halflings-regular.ttf - HTTP 404.

I have read a number of other similar questions about this on stack overflow but the solutions dont seem to fit with my application.

Most of the suggested fixes deal with the app/assetts/stylesheets/bootstrap_and_overrides.css.less for those interested this is the current contents of this file :

@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;

Perhaps the iconspritepath in this file is wrong? I am not sure what it should be though?

Please help!

I found out the problem. It seems by default in ruby on rails it is setup to use fontawesome glyphicons instead of the default glyphicons with bootstrap.

Therefore I just needed to use a different css class for which I used this site :

http://fortawesome.github.io/Font-Awesome/icons/

Fontawesome definitely is better than the default glyphicons so I now used :

<span class="fa fa-users fa-2x"></span>

for my person icon!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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