Why always Web component(Custom component)'s shadow-root copy own root's style

22 views Asked by At

I create and use a web component.

and I give a some style to web component. After then always web component inject own style to shadow-root.

This is code.

<custom-element style="width: 50%; border: 1px solid red" />

And I can see this dom structure in devTool's element tab

<custom-element style="width: 50%; border: 1px solid red">
   #shadow-root
   <div style="width: 50%; border: 1px solid red">
      ~~~~
   </div>
</custom-element>

But, I want to give a style to only custom-element. Or give a style to only shadow-root, How can I do this?

....................................................

0

There are 0 answers