以简单形式更改标签的颜色
Change color of the label in a 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>
这是因为 CSS specificity. But, from the documentation's example,每个 label
都有 control-label
class,所以样式改为:
.control-label{
color: white !important; // some color
}
尝试为 label
添加单独的 class,然后为 class
添加 css
示例:
添加 class 名称为 label-style
然后添加样式如下
.label-style{
color: white;
}
希望这会有所帮助:)
如何在简单表单中更改字段标签的颜色?现在它是黑色的,但我希望它是白色的。我正在使用 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>
这是因为 CSS specificity. But, from the documentation's example,每个 label
都有 control-label
class,所以样式改为:
.control-label{
color: white !important; // some color
}
尝试为 label
添加单独的 class,然后为 class
css
示例:
添加 class 名称为 label-style
然后添加样式如下
.label-style{
color: white;
}
希望这会有所帮助:)