以简单形式更改标签的颜色

时间:2016-05-31 12:06:25

标签: ruby-on-rails simple-form

如何在简单表格中更改字段标签的颜色?现在它是黑​​色但我希望它是白色的..我正在使用scss。 我在下面尝试了这段代码,但它不起作用:

label {
    float: left;
    width: 100px;
    text-align: right;
    margin: 2px 10px;
    color: #ffffff;

  }

和字段的html输出

<div class="form-group email optional user_email"><label class="email optional control-label" for="user_email">Email</label><input class="string email optional form-control" placeholder="user@domain.com" type="email" value="test@gmail.com" name="user[email]" id="user_email"></div>

2 个答案:

答案 0 :(得分:1)

那是因为CSS specificity。但是,from the documentation's example,每个label都有control-label类,因此请将其设置为样式:

.control-label{
     color: white !important; // some color
}

答案 1 :(得分:1)

尝试为label添加单独的类,然后为该类添加css

示例:

将类名添加为label-style,然后添加如下所示的样式

.label-style{
   color: white;
 }

希望这会有所帮助:)