I am trying to build a chrome extension which injects an HTML popup on the host page via content script.
I am adding this popup using shadowRoot to avoid collisions with the main page. Also, I am using bootstrap on the popup for styling. One issue which is happening is that, bootstrap defines many of its component properties in rem units which are relative to the font-size of page root(html element) and not the shadow root. This messes up with popup's CSS as some pages have very small font-size defined on their root.
I wanted to understand if its possible to define a new root with font-size for the ShadowRoot or somehow override the root value being used in the popup via bootstrap!
Thanks a lot, really appreciate any help!
I had the same exact problem but I was using tailwind instead of bootstrap. So all I had to do was convert the generated CSS values into
pxinstead ofemorrem.I updated my
tailwind.config.jslike this-Source: https://github.com/tailwindlabs/tailwindcss/issues/1232#issuecomment-754804258
One catch here is, it won't work if you don't add any tailwind class, e.g
<div>Hello</div>won't work<div class="text-base">Hello</div>worksTo handle these cases as well, I used
in shadow DOM (as pointed out in comment).