跳到正文
原文
Simon Willison·· 2026-09-24AI 评分30

用实时示例讲解 Shadow roots

Shadow roots, explained with live examples

AI 导读

交互示例讲解 shadow roots:它创建带私有样式表的隔离 DOM 树,元素以特定、受控方式与页面 DOM 交互。这些实时例子演示样式封装。继承同样包含在这组交互演示中。

正文 · 原文

Tool Shadow roots, explained with live examples — Learn about shadow DOM through interactive examples that demonstrate style encapsulation, inheritance, slots, parts, and JavaScript access. Explore how shadow roots create isolated DOM trees with private stylesheets and elements that interact with the page DOM in specific, controlled ways.

Prompt to Fable 5.1 Medium:

Build an artifact to explain shadow roots in CSS with interactive examples

来源:Simon Willison · simonwillison.net