CSS有一个:模糊选择器(伪类)? [英] Does CSS have a :blur selector (pseudo-class)?
问题描述
我知道有一个:focus
选择器。我似乎找不到使用或文档的:blur
选择器。是否有一个?
I know there is a :focus
selector. I can't seem to find use of or documentation of a :blur
selector. Is there one?
推荐答案
没有:blur
在CSS中。
动态伪类别,像其他伪类别以及实际上所有其他选择器一样,表示状态;它们不会在文档树中表示事件或状态之间的转换。简单来说::focus
伪类表示在焦点的元素;它不表示只是接收到焦点的元素,也不存在:blur
伪类来表示具有<
The dynamic pseudo-classes, like other pseudo-classes and in fact all other selectors, represent states; they do not represent events or transitions between states in terms of the document tree. To wit: the :focus
pseudo-class represents an element that is in focus; it does not represent an element that has just received focus, nor does there exist a :blur
pseudo-class to represent an element that has just lost focus.
类似地,这适用于:hover
伪类。虽然它代表一个在其上具有指向设备的元素,但是对于刚刚指向的元素,则不存在:mouseover
伪类>也不是:mouseout
伪类。
Similarly, this applies to the :hover
pseudo-class. While it represents an element which has a pointing device over it, there is neither a :mouseover
pseudo-class for an element that has just been pointed to nor a :mouseout
pseudo-class for an element that has just been pointed away from.
如果您需要将样式应用于不在焦点的元素,您有两种选择:
If you need to apply styles to an element that is not in focus, you have two choices:
-
使用
:not(:focus)
(浏览器支持较少):
Use
:not(:focus)
(with less browser support):
input:not(:focus), button:not(:focus) {
/* Styles for only form inputs and buttons that do not have focus */
}
声明适用于任何元素的规则,无论其焦点状态如何,焦点:
Declare a rule that applies to any element regardless of its focus state, and override for elements that have focus:
input, button {
/* Styles for all form inputs and buttons */
}
input:focus, button:focus {
/* Styles for only form inputs and buttons that have focus */
}
这篇关于CSS有一个:模糊选择器(伪类)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!