How to apply common CSS styles to many Shadow Roots at once?

后端 未结 1 2126
南旧
南旧 2020-12-06 20:58

Consider, I have few elements which use Shadow DOM to hide their internal div-soup and layout.

Even tough they are different, they share the same CSS style sheet, as

1条回答
  •  无人及你
    2020-12-06 21:25

    UPDATE: 2019 - Use Constructable stylesheets

    As of 2019, Constructable stylesheets is the approach to apply stylesheets to shadow DOM and web components in general. Read more about it here.

    Previous answer:

    You can use an import CSS rule at the first line of a ...

    Then import the