Ruby on Rails Bootstrap Glyphicons not working

后端 未结 17 2037
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:26

    I think you might be having a problem with the asset pipeline

    You want to change bootstrap.css to bootstrap.css.scss and then replace where it uses

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

    with font-path (look at section 2.3.2 - CSS and Sass)

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

    Also in your config/environments/production.rb

    # Precompile additional assets
    config.assets.precompile += %w( .svg .eot .woff .ttf )
    

    In your config/application.rb

    # Add the fonts path
    config.assets.paths << Rails.root.join('app', 'assets', 'fonts')
    

    Check out another SO post for a similar problem

    Hope this helps

提交回复
热议问题