Ruby on Rails Bootstrap Glyphicons not working

后端 未结 17 2033
Happy的楠姐
Happy的楠姐 2020-12-02 07:43

I have added bootstrap to my site. Here is the structure I am using. (I cannot whatsoever remove the bootstrap.css file since it I modified it to my liking).



        
相关标签:
17条回答
  • 2020-12-02 08:39

    I was also struggling to make boostrap3 glyphicon work in rails 4. I solved it by adding

    @font-face {
      font-family: 'Glyphicons Halflings';
      src: url(asset_path('glyphicons-halflings-regular.eot'));
      src: url(asset_path('glyphicons-halflings-regular.eot?#iefix')) format('embedded-opentype'), url(asset_path('glyphicons-halflings-regular.woff')) format('woff'), url(asset_path('glyphicons-halflings-regular.ttf')) format('truetype'), url(asset_path('glyphicons-halflings-regular.svg#glyphicons_halflingsregular')) format('svg');
    }`
    

    to application.css.scss file and

    config.assets.paths << "#{Rails}/vendor/assets/fonts"
    

    to application.rb file.

    0 讨论(0)
  • 2020-12-02 08:39

    Make sure you have set

    # config/environments/production.rb
    config.assets.compile = true
    

    And add fonts to precompile list

    # config/initializers/assets.rb
    config.assets.precompile += %w(*.eot *.svg *.ttf *.woff *.woff2)
    
    0 讨论(0)
  • 2020-12-02 08:40

    In my index.html.slim file, I replaced span.glyphicon.glyphicon-calendar with span.fa.fa-calendar and it worked.

    0 讨论(0)
  • 2020-12-02 08:44

    Provided that you have the glyphicons files in app/assets/fonts (if you don't, you can download them from the bootstrap-saas repo), create app/assets/stylesheets/fonts.scss and add the following:

    @font-face {
      font-family: 'Glyphicons Halflings';
      src: font-url('glyphicons-halflings-regular.eot');
      src: font-url('glyphicons-halflings-regular.eot?#iefix') format('embedded-opentype'),
      font-url('glyphicons-halflings-regular.woff') format('woff'),
      font-url('glyphicons-halflings-regular.ttf') format('truetype'),
      font-url('glyphicons-halflings-regular.svg#glyphicons_halflingsregular') format('svg');
    }
    
    0 讨论(0)
  • In Rails 4, with sass, Bootstrap 3.2.0, and the bootstrap-sass gem use:

    @import "bootstrap";
    @import "bootstrap/theme";
    
    0 讨论(0)
提交回复
热议问题