Phi*_*899 1 ruby-on-rails asset-pipeline twitter-bootstrap twitter-bootstrap-rails ruby-on-rails-4
我无法让glyphicons与bootstrap 3和rails一起使用.我已经在互联网上找到了灵感,没有找到任何帮助.在我的bootstrap.css文件中,我有:
@font-face {
font-family: 'Glyphicons Halflings';
src: url('/assets/glyphicons-halflings-regular.eot');
src: url('/assets/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');
}
Run Code Online (Sandbox Code Playgroud)
在application.rb中,我有:
config.assets.enabled = true
config.assets.paths << "#{Rails.root}/app/assets/fonts"
config.assets.precompile += %w( .svg .eot .woff .ttf )
Run Code Online (Sandbox Code Playgroud)
我已经尝试过跑:
rake资产:预编译RAILS_ENV =开发
在application.js我有:
//= require jquery
//= require jquery_ujs
//= require_tree .
//= require bootstrap
Run Code Online (Sandbox Code Playgroud)
在application.css我有:
*= require_self
*= require_tree .
*= require bootstrap
*/
Run Code Online (Sandbox Code Playgroud)
我的所有字体都存储在资源/字体中
我已经看过以下内容,但没有一个有效:
Bootstrap 3 + Rails 4 - 某些Glyphicons不工作
我怎样才能解决这个问题?
如果您使用的是bootstrap-sass gem,请按照下面的设置进行操作.如果不试一试,这是我用过的最简单的bootstrap设置.
顺便说一句,我目前正在使用rails版本4.1.6和4.1.8
两颗宝石
gem 'bootstrap-sass'
gem 'autoprefixer-rails'
Run Code Online (Sandbox Code Playgroud)
您的Application.js应如下所示(turbolinks可选)
/app/assets/javascripts/application.js
//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require bootstrap-sprockets
//= require_tree .
Run Code Online (Sandbox Code Playgroud)
样式表应该有这两个导入
/app/assets/stylesheets/application.scss
@import "bootstrap-sprockets"
@import "bootstrap"
Run Code Online (Sandbox Code Playgroud)
如果此设置不起作用,请尝试使用font-path http://guides.rubyonrails.org/asset_pipeline.html#coding-links-to-assets
第2.3.2节css和sass
所以你的代码将来自:
url('/assets/glyphicons-halflings-regular.eot');
Run Code Online (Sandbox Code Playgroud)
到font-path('glyphicons-halflings-regular.eot');
| 归档时间: |
|
| 查看次数: |
5226 次 |
| 最近记录: |