选中时更改复选框标签的颜色 [英] Changing color of checkbox label when checked

查看:119
本文介绍了选中时更改复选框标签的颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试更改复选框标签的颜色。我之前在其他网站上做过这个,但由于某种原因,我的代码只是在这个上没有工作。我使用Drupal 7和bootstrap 3 +。

I am trying to change the color of my checkbox's label when it is checked. I've done this before on other sites, but for some reason my code just isn't working on this one. I am using Drupal 7 with bootstrap 3+.

我的复选框如下所示:

My checkbox looks like this:

<div class="checkbox">
    <input class="onlinecheckbox" type="checkbox" name="dealtype[]" id="prov1" onchange="this.form.submit()" value="booking" checked="">
    <label for="prov1">Booking</label>
</div>

我的css如下:

My css is as follows:

.onlinecheckbox input[type="checkbox"] + label {
    color: #ffffff;
}

.onlinecheckbox input[type="checkbox"]:checked + label {
    color: #428bca;
}


推荐答案



You should place .onlinecheckbox after input[type="checkbox"]:

input[type="checkbox"].onlinecheckbox + label {
    color: #ffffff;
}

input[type="checkbox"].onlinecheckbox:checked + label {
    color: #428bca;
}

这篇关于选中时更改复选框标签的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆