如何样式 :root 基于自定义元素属性

How to style :root based on Custom Element Attribute

更新:参见:

不可以吗?

完全忽略此样式规则

您忘记了 :host():

的括号

elem.attachShadow({mode: 'open'})
    .innerHTML = `
    <style>
      :host([player="X"]) { 
        display: inline-block;
        background: red;
        padding 1em; 
      }
    </style>
    Hello World`
<game-toes id=elem player="X"></game-toes>