css - 更改 Rails Bootstrap 主体颜色

标签 css ruby-on-rails twitter-bootstrap

我正在尝试将正文背景颜色更改为自定义颜色。通常我已经将自定义 css 写入 bootstrap_and_override.css 文件,它可以工作,但使用 body 标签则不行。这里的一些人建议查找并覆盖标准的 body css 设置,但是 sublime-text 就像我一样,无法在元素的任何地方找到相应的行。

也许我对 body 标签的寻址有误?我写过:

  body {
    background-color: #F8F8F8;
  }

因为 body 标签似乎没有任何可以用来寻址的自定义类。在 chrome web inspector 中,我可以看到这一点,所以我的代码似乎被注意到了,但后来被覆盖了。但我就是找不到发生这种情况的地方。

chrome analytics picture

划掉的背景颜色是正确的,不是#FFF。

我希望有人知道这个问题的答案,不会这么难吧?非常感谢!

更新: 这里是application.css的内容

/*
 * 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 top of the
 * compiled file, but it's generally better to create a new file per style scope.
 *
 *= require_self
 *= require_tree .
 */

更新 2: 以下是样式表文件夹的内容:
应用程序.css
bootstrap_and_overrides.css
bootstrap_and_overrides.css.less
...其余的是站点特定文件,以 .css.scss 结尾

最佳答案

您可以使用 !important。我会谨慎行事,因为这不是最佳做法。用 !important 强制覆盖有它的位置,应该只在必要时使用。

body {
    background-color: #F8F8F8 !important;
  }

我个人使用 !important 的一个例子是用于调试和覆盖由 javascript 生成的内联 CSS 设置的规则,如果我没有编辑 javascript/插件的权限。

关于css - 更改 Rails Bootstrap 主体颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17906809/

相关文章:

javascript - 如何用模态文本框填充我的文本框

css - Bootstrap 不适用于开发中的 Rails 4.2.4 应用程序

html - 让图片横向滚动

jquery - 用另一个 div 的内容替换一个 div

ruby-on-rails - 用 cucumber 和 pickle 记录 id [Rails]

ruby-on-rails - AcitveRecord 不会接受_nested_attributes_for 具有嵌套现有记录的新关联记录

Rails 3 的 Javascript 组织策略

css - 无法删除 CSS 中的填充/边距

html - 试图将一个 div 标签置于一个 section 标签的中心

javascript - 根据元素是否折叠更改 Bootstrap 折叠按钮中的文本