`:is()`不适用于伪元素
<!DOCTYPE html>
<html lang="zh-Hans">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Test</title>
<link rel="stylesheet" href="https://unpkg.com/normalize.css" />
<style>
body {
background: #000;
color: #eee;
}
button::before {
content: 'foo';
}
/*
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不幸的是,这不是当前规格的一部分,尽管尚不清楚 /尚未解决。
除了当前CSS选择器级别第4级编辑草案(2021年7月2日)规范中的Temani的报价外,同一规范引用了注释,该注释是 3.6.3。伪级伪元素。
手指交叉,这是在未来的草稿或最终规范中解决的。
我将在以下测试中发布相同的问题。
https://codepen.io/augustography/pen/pen/pen/ojmprzq
Unfortunately it's not part of the current spec, although is still unclear / unresolved.
In addition to Temani's quote from the current CSS Selectors Level 4 Editors Draft (2 July 2021) specification, the same specification referenced notes this as an unresolved issue in 3.6.3. Pseudo-classing Pseudo-elements.
Fingers crossed this is resolved in either a future draft or the final Specification.
I was going to post the same question with the following tests.
https://codepen.io/augustography/pen/OJmprzq