简体   繁体   中英

Embed JavaScript and let it use local CSS

I've created a simple html web page using bootstrap. I've also created a "nice looking" form with Svelte that also uses bootstrap.

The svelte form is hosted on another server/domain. I embed it on my html page by placing a -Tag and than placing my custom html tag where I want to see it.

Embedding the form is no problem, technically everything works but: I would like to remove the bootstrap library from the component because otherwise I load bootstrap twice.

When I remove bootstrap from the form, it loses its style. Using the "refer" option in is no solution.

Do you have any idea how I can make the embeded form use the bootstrap css from the page that it is embeded on?

I just found out that the problem is the so called "Shadow DOM", which is used by Svelte. It protects the svelte component from being modified by global css.

At the moment there is no official way to disable the Shadow DOM:(

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM