我試圖覆蓋我的bootstrap_and_overrides.css.less文件中的變量,根據文件中的說明。我知道文件被解析,因爲如果我引入語法錯誤,應用程序將不會加載,但設置較少的變量,例如使用twitter-bootstrap-rails gem的Bootstrap覆蓋不會生效?
@navbar-default-color: red;
沒有任何效果。這裏是我的application.css:
/*
*= require_tree .
*= require_self
*= require rails_bootstrap_forms
*= require bootstrap_and_overrides
*/
從Gemfile中摘錄:
source 'https://rubygems.org'
ruby '2.0.0'
gem 'rails', '4.1.4'
gem 'sass-rails', '~> 4.0.3'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0', group: :doc
gem 'spring', group: :development
gem 'bootstrap-sass'
gem 'high_voltage'
gem "therubyracer"
gem "less-rails"
gem "twitter-bootstrap-rails"
gem "bootstrap_form"
這裏是我的bootstrap_and_overrides.css.less文件:
@import "twitter/bootstrap/bootstrap";
@iconSpritePath: image-url("twitter/bootstrap/glyphicons-halflings.png");
@iconWhiteSpritePath: image-url("twitter/bootstrap/glyphicons-halflings-white.png");
@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");
@import "fontawesome/font-awesome";
@import "twitter/bootstrap/glyphicons.less";
// Your custom LESS stylesheets goes 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
@navbar-default-color: red;
@navbar-height: 1000px;
@navbar-default-color: red;
在可能相關的問題,我無法在我的html中包含glyphicons。
編輯:當我預編譯並推送到生產(heroku)時,少量變量在生產中被解釋。看起來這可能是一個與發展有關的問題。
你試過了@ navbar-default-color:red!importnat; – bkdir 2014-08-27 16:01:38
這應該不重要,但試過了,它不起作用。 – parker 2014-08-27 16:15:38
對不起,這個愚蠢的問題,但你真的看看編譯的CSS?或者你只是在瀏覽器中測試它? – 2014-08-29 21:18:44