繁体   English   中英

覆盖Rails SASS引导CSS

[英]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.scssapplication.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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM