简体   繁体   English

CSS 复选框样式独特的类

[英]CSS Checkbox styling unique classes

Is there a good way to select an input that has unique classes.有没有一个好方法来 select 一个具有唯一类的input

At the moment this will do...目前,这将...

input[type="checkbox"]:checked + label {....}

But what if I want to grab the label by the class name usethis ?但是,如果我想通过 class 名称来获取usethis怎么办? Code below -下面的代码-

<div class="checkbox">
   <input id="c1" class="rounded-input" type="checkbox" rel="performance" onchange="change()" />
   <label class="usethis" for="c1">Performance</label>
</div>

See if this works看看这是否有效

input[type="checkbox"]:checked + .usethis {
  color: red;
  font-size: 5rem;  // i have given some random styles here
}

This style will only come when the checkbox is checked, and if you have another checkbox in the page without the label having the class.usethis, this style wont be applied to those checkboxes这种样式只有在选中复选框时才会出现,如果您在页面上还有另一个复选框,而没有label,其中ZA2F2ED4F2ED4F8EBCBBC2CBBBBBB4C21A21A29DC40AB61DZ.USETES,则使用此类单。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM