Use a remote stylesheet inside a template tag (with shadow dom)

后端 未结 4 709
生来不讨喜
生来不讨喜 2021-01-01 22:13

I am trying to make a semi-resuseable widget but I am running into a problem. I am trying to encapsulate a some CSS code inside a shadow root so that it does not affect the

4条回答
  •  执笔经年
    2021-01-01 22:34

    Let add to the answer . Now direct tag is supported in shadow dom.

    You can directly use

    
      
    

    Check they has been update by whatwg and W3C

    Useful link for using css in shadow dom.

    https://w3c.github.io/webcomponents/spec/shadow/#inertness-of-html-elements-in-a-shadow-tree https://github.com/whatwg/html/commit/43c57866c2bbc20dc0deb15a721a28cbaad2140c

    https://github.com/w3c/webcomponents/issues/628

    Direct css link can be use in shadow dom

    Thanks.

提交回复
热议问题