CSS3:未选中的伪类 [英] CSS3 :unchecked pseudo-class
问题描述
我知道有一个官方的CSS3 :checked
伪类,但有一个:unchecked
类,它们是否具有相同的浏览器支持?
Sitepoint的引用没有提及,但 whatwg spec (无论是什么)。
我知道当:checked
和:not()
伪类被组合,但我仍然好奇:
input [type =checkbox]:not(:checked){
/ * styles * /
}
w3c建议使用相同的方法
/ p>
未选中的复选框可以使用否定伪类选择:
:not(:checked)
事实上,W3C的报价是取自选择器4规格。由于选择器4 建议使用
:not(:checked)
,所以可以假设没有相应的:unchecked
pseudo。浏览器对:not()
和:checked
的支持是完全相同的, p>
这可能与
:enabled
和:disabled
状态,特别是因为元素既不能被启用也不被禁用(即语义完全不适用),但是对于这种不一致性没有任何解释。
(
:indeterminate
不计数,因为一个元素同样可以不被取消选中,选中或不确定,因为语义不适用。)
I know there is an official CSS3
:checked
pseudo-class, but is there an:unchecked
pseudo-class, and do they have the same browser support?Sitepoint's reference doesn't mention one, however this whatwg spec (whatever that is) does.
I know the same result can be achieved when the
:checked
and:not()
pseudo-classes are combined, but i'm still curious:input[type="checkbox"]:not(:checked) { /* styles */ }
Edit:
The w3c recommends the same technique
An unchecked checkbox can be selected by using the negation pseudo-class:
:not(:checked)
解决方案
:unchecked
is not defined in the Selectors or CSS UI level 3 specs, nor has it appeared in level 4 of Selectors.In fact, the quote from W3C is taken from the Selectors 4 spec. Since Selectors 4 recommends using
:not(:checked)
, it's safe to assume that there is no corresponding:unchecked
pseudo. Browser support for:not()
and:checked
is identical, so that shouldn't be a problem.This may seem inconsistent with the
:enabled
and:disabled
states, especially since an element can be neither enabled nor disabled (i.e. the semantics completely do not apply), however there does not appear to be any explanation for this inconsistency.(
:indeterminate
does not count, because an element can similarly be neither unchecked, checked nor indeterminate because the semantics don't apply.)这篇关于CSS3:未选中的伪类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文