【发布时间】:2015-03-17 05:26:06
【问题描述】:
对于下面的 CSS,我如何共同使用属性和相邻选择器?
.onoff-checkbox:checked + .onoff-label .onoff-inner {margin-left: 0;}
.onoff-checkbox:checked + .onoff-label .onoff-switch {right: 0px;}
我正在使用它来创建 CSS 切换样式复选框,并且希望在页面上拥有多个复选框?使用以下 HTML 代码(示例):
<input type="checkbox" name="onoff" class="onoff-checkbox-1" id="myonoff" checked>
...
<input type="checkbox" name="onoff" class="onoff-checkbox-2" id="myonoff" checked>
我已经尝试了以下 -
input[class*="onoff-checkbox"]:checked + label[class*="onoff-label"] span[class*="onoff-inner"]
...
什么是正确的语法。感谢您的帮助。
这是试用的代码 - https://jsfiddle.net/vedanta_/8z3sqatf/ 原代码改编自-https://proto.io/freebies/onoff/
【问题讨论】:
-
需要查看更多 HTML。您显示的内容不足以代表您拥有的选择器 - 即缺少标签。
标签: html css css-selectors