How to use global css styles in shadow dom

前端 未结 4 726
孤城傲影
孤城傲影 2021-01-07 22:58

Shadow dom encapsulate css styles, selectors don\'t cross the shadow boundary.

Question: How to use global common css styles in shadow

4条回答
  •  攒了一身酷
    2021-01-07 23:38

    You do it via ::shadow pseudo-element. Like this:

    ::shadow .redColor
    {
        background-color: red;    
    }
    

    That will apply styling to all elements inside shadow trees with .redColor class.

    More info + other styling possibilities in this great article: Shadow DOM 201

提交回复
热议问题