【问题标题】:Bootstrap Rails - Change background color, not working?Bootstrap Rails - 更改背景颜色,不起作用?
【发布时间】:2014-02-14 07:43:56
【问题描述】:

我基于 RailsTutorial 构建了一个 Ruby on Rails 站点。我正在尝试更改一些颜色,但我无法弄清楚。

我想更改背景颜色 [页面正文] 和菜单文本的颜色。我在哪里可以做到这一点?

我当前的 custom.css.scss:

@import "bootstrap";

/* mixins, variables, etc. */

$grayMediumLight: #eaeaea;

@mixin box_sizing {
  -moz-box-sizing: border-box;
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
}

/* universal */

html {
  overflow-y: scroll;
}

body {
  padding-top: 60px;
}

section {
  overflow: auto;
}

textarea {
  resize: vertical;
}

.center {
  text-align: center;
  h1 {
    margin-bottom: 10px;
  }
}
table td {
  padding:0px 25px 0px 0px;
}
table th {
  text-align: left;
  padding:0px 25px 0px 0px;
}



/* bootstrap */

.navbar-inner {
  background-color: white; /* background color will be black for all browsers */
  background-image: none;
  background-repeat: no-repeat;
  filter: none;
}


/* typography */

h1, h2, h3, h4, h5, h6 {
  line-height: 1;
}

h1 {
  font-size: 3em;
  letter-spacing: -2px;
  margin-bottom: 30px;
  text-align: center;
}

h2 {
  font-size: 1.2em;
  letter-spacing: -1px;
  margin-bottom: 30px;
  text-align: center;
  font-weight: normal;
  color: $grayLight;
}

p {
  font-size: 1.1em;
  line-height: 1.7em;
}
p2 {
  font-size: 1.1em;
  line-height:1.7em;
  font-weight: bold;
}

/* header */

#logo {
  float: left;
  margin-right: 10px;
  font-size: 1.7em;
  color: black;
  letter-spacing: -1px;
  padding-top: 9px;
  font-weight: bold;
  line-height: 1;
  &:hover {
    color: white;
    text-decoration: none;
    background-color: black;
  }
}
...

谢谢

【问题讨论】:

    标签: css ruby-on-rails ruby-on-rails-3 twitter-bootstrap


    【解决方案1】:

    默认情况下,Bootstrap 有很多自定义项。你可以在这里找到所有选项http://getbootstrap.com/customize/

    只需使用 sass 变量而不是 less。

    $body-bg: #fff;
    
    $navbar-default-color: #000;
    
    $navbar-default-link-color: #000;
    

    等等……你会得到你想要的

    【讨论】:

      【解决方案2】:

      改变导航栏的颜色

      .navbar {
         background-color: red;
      }
      

      更改导航栏导航链接颜色

      .navbar-nav > li > a {
         color: blue;
      }
      

      【讨论】:

      • 抱歉,我不清楚。文本颜色有效,但正文的背景颜色(不是导航栏)谢谢
      • 那为什么不在body上添加css
      • 正文 { 背景色:红色; }
      • 想通了。需要在scaffolds.css.scss 中而不是custom.css.scss 中。谢谢
      【解决方案3】:

      试试

      div.navbar{
      background: red;
      color:#fff
      }
      

      根据需要更改颜色。

      【讨论】:

        猜你喜欢
        • 2014-04-09
        • 2013-10-21
        • 1970-01-01
        • 2016-06-11
        • 1970-01-01
        • 1970-01-01
        • 2016-11-28
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多