为单个输入ID定义CSS样式,而不是输入[type = checkbox]

use*_*574 5 css checkbox input

这是我的复选框

<input type="checkbox" name="MyName[]" value="A1" id="A1"/>
<label for="Filter"></label>
<input type="checkbox" name="MyName[]" value="A2" id="A2"/>
<label for="Filter"></label>
Run Code Online (Sandbox Code Playgroud)

这是我的风格

input[type=checkbox] {..}
input[type=checkbox] + label {background:'image-1'}
input[type=checkbox]:checked + label {background:'image-2'}
Run Code Online (Sandbox Code Playgroud)

我需要使用不同的已选中和未选中图像为每个复选框设置样式.

我想要引用ID而不是input[type=checkbox]我的CSS.

怎么做?

Bra*_*roy 11

input#A1
input#A2
input#A1:checked
input#A2:checked
Run Code Online (Sandbox Code Playgroud)

但是input如果您不想要,则无需指定标记名称().但它可能有用!(特别是课程)

阅读文档中有关(ID-)选择器的更多信息.