LoginSignup
0
3

More than 5 years have passed since last update.

RailsでBootstrapのアイコンが表示されない時の解決法

Posted at

実行環境

Rails 4.2.6
Bootstrap 3.3.7

Gem

gem 'pry-rails'
gem 'devise'
gem 'paperclip'
gem 'kaminari'
gem 'therubyracer'
gem 'twitter-bootstrap-rails'
gem 'bootstrap-material-design'
gem 'bootstrap-sass'

ちなみにgemはこんな感じです。

エラー内容

アイコンが表示されず、四角にバツがついたマークが出る。

原因

アイコンはfontsフォルダから読み込まれるが、これが何らかの原因で読み込まれていない。

解決法

そもそもfontsフォルダがないので、Bootstrapの公式サイトからダウンロードして来たfontsフォルダをapp/assets/の下に置く。
その後、app/assets/stylesheets/application.scss内に以下を追記する。

application.scss
@font-face {
  font-family: Glyphicons Halflings;
  src: url(‘/assets/glyphicons-halflings-regular.eot’);
  src: url(‘/asstes/glyphicons-halflings-regular.eot?#iefix’) format(embedded-opentype),
  url(‘/assets/glyphicons-halflings-regular.woff’) format(woff),
  url(‘/assets/glyphicons-halflings-regular.ttf’) format(truetype),
  url(‘/assets/glyphicons-halflings-regular.svg#glyphicons-halflingsregular’) format(svg);
}
0
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
3