poo-11
poo-11

Reputation: 11

Encapsulating CSS code in javascript plugin

I'm writing JS plugin which will be placed in several different websites. Those websites are using different styling, some Bootstrap, some Bulma and some just custom styles.

My plugin is generating DOM elements like divs, inputs, selects. I want to style those elements on my own. How to make this plugin look the same in any website which it will be embed?

Upvotes: 0

Views: 53

Answers (1)

leprechaun
leprechaun

Reputation: 31

Maybe creating Shadow DOM elements would help. Then you will be able to add your custom DOM elements and they will not be affected by whatever is outside. See here: https://developer.mozilla.org/en-US/docs/Web/Web_Components/Using_shadow_DOM

Upvotes: 2

Related Questions