Does CSS have a :blur selector (pseudo-class)?(CSS 是否有 :blur 选择器(伪类)?)
问题描述
我知道有一个 :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?
推荐答案
CSS 中没有 :blur
伪类.
There is no :blur
pseudo-class in 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)
(浏览器支持较少):
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 是否有 :blur 选择器(伪类)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:CSS 是否有 :blur 选择器(伪类)?
基础教程推荐
- 如何使用TypeScrip将固定承诺数组中的项设置为可选 2022-01-01
- Chart.js 在线性图表上拖动点 2022-01-01
- Electron 将 Node.js 和 Chromium 上下文结合起来意味着 2022-01-01
- html表格如何通过更改悬停边框来突出显示列? 2022-01-01
- 我可以在浏览器中与Babel一起使用ES模块,而不捆绑我的代码吗? 2022-01-01
- 用于 Twitter 小部件宽度的 HTML/CSS 2022-01-01
- 如何使用JIT在顺风css中使用布局变体? 2022-01-01
- 自定义 XMLHttpRequest.prototype.open 2022-01-01
- Vue 3 – <过渡>渲染不能动画的非元素根节点 2022-01-01
- 直接将值设置为滑块 2022-01-01