我需要用 CSS 设置它,而不是 jquery。
选择器用于
all labels which do not have a sibling that is a checkbox or radio component.
一个例子是:
<span>
<input id="item" type="checkbox">
<label for="item">Data</label>
</span>
这是因为我有将标签设置为 12px 的 CSS,但它会影响 asp:checkboxes 和 asp:radio...,但我不希望它们受到影响。
最佳答案
没有特定类型的兄弟元素的元素没有 CSS 选择器。
但是如果你能保证你的结构总是一个input
后跟一个label
,那么你可以使用next-sibling combinator使用 :not()
来匹配 label
:
input:not([type="checkbox"]):not([type="radio"]) + label
否则,您将不得不向这些标签添加类,或使用 jQuery。
关于css - 没有兄弟输入类型=复选框|| radio 的标签的 CSS 选择器是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12356651/