[英]Overriding Bootstrap variables in Rails with bootstrap-sass gem
[英]Overriding Rails SASS Bootstrap CSS
我正在使用Rails 4.1.8,sass-rails 4.0.3和bootstrap-sass 3.3.3,我很難覆蓋一些CSS。
我的application.css.sass文件看起來像這樣
/*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
*
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
* compiled file so the styles you add here take precedence over styles defined in any styles
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
* file per style scope.
*
*= require_tree .
*= require_self
*/
@import "bootstrap-sprockets"
@import "bootstrap"
我還有一個名為header.css.scss的文件,我試圖給header標簽設置字體大小,並且它不會改變。 但是,我測試時其他3個屬性正確更改。
header{
background: #0099da;
color: #ffffff;
font-size: 2em;
height:100px;
}
當我嘗試更改圖例標簽時,也會發生相同的情況。
您需要在 bootstrap
之后導入header.css.scss
。
假裝header.css.scss
與application.css.scss
放在同一文件夾中,它應類似於:
/*
* (…)
*
*= require_self
*= require_tree .
*/
@import "bootstrap-sprockets"
@import "bootstrap"
我只是簡單地更改了Sprockets需求順序。
但是,我強烈建議您專門導入文件,以避免由於錯誤的導入順序而導致的優先噩夢。
/*
* (…)
*
*= require_self
*= require header.css.scss
*/
@import "bootstrap-sprockets"
@import "bootstrap"
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.