这是
实验性技术
检查
浏览器兼容性表格
要小心谨慎在生产中使用这之前。
CSSPseudoElement
interface represents a pseudo-element that may be the target of an event or animated using the
Web 动画 API
. Instances of this interface may be obtained by calling
Element.pseudo()
.
CSSPseudoElement.element
只读
元素
of the pseudo-element.
CSSPseudoElement.type
只读
CSSOMString
.
CSSPseudoElement
extends
EventTarget
, so it inherits the following methods:
EventTarget.addEventListener()
Registers an event handler of a specific event type on the pseudo-element.
EventTarget.dispatchEvent()
Dispatches an event to this pseudo-element.
EventTarget.removeEventListener()
Removes an event listener from the pseudo-element.
Using pseudo-elements, most modern browsers will automatically add quotation marks around text inside a
<q>
element. (A style rule may be needed to add quotation marks in older browsers.) The example below demonstrates the basic properties of the
CSSPseudoElement
object representing the opening quotation mark.
const element = document.querySelector('q');
const cssPseudoElement = element.pseudo('::before');
console.log(cssPseudoElement.element); // Outputs [object HTMLQuoteElement]
console.log(cssPseudoElement.type); // Outputs '::before'
| 规范 | 状态 | 注释 |
|---|---|---|
|
CSS Pseudo-Elements Level 4
The definition of 'CSSPseudoElement' in that specification. |
工作草案 | 初始定义。 |
The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
更新 GitHub 上的兼容性数据| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
CSSPseudoElement
|
Chrome No | Edge No |
Firefox
75
Disabled
|
IE No | Opera No | Safari No | WebView Android No | Chrome Android No |
Firefox Android
63
Disabled
|
Opera Android No | Safari iOS No | Samsung Internet Android No |
element
|
Chrome No | Edge No |
Firefox
75
Disabled
|
IE No | Opera No | Safari No | WebView Android No | Chrome Android No |
Firefox Android
67
Disabled
|
Opera Android No | Safari iOS No | Samsung Internet Android No |
type
|
Chrome No | Edge No |
Firefox
75
Disabled
|
IE No | Opera No | Safari No | WebView Android No | Chrome Android No |
Firefox Android
63
Disabled
|
Opera Android No | Safari iOS No | Samsung Internet Android No |
完整支持
不支持
实验。期望将来行为有所改变。
用户必须明确启用此特征。
使用非标名称。