简体   繁体   English

如何防止影响我的小部件的页面的CSS?

[英]How to prevent CSS of the page affecting my widget?

I am building widget with JS and without iframe. 我正在使用JS和没有iframe构建小部件。 I need some help on how to prevent styles from page affecting my widget. 我需要一些帮助,以防止页面中的样式影响我的小部件。 Initially i build it with shadow dom, but it has no support for firefox. 最初我用阴影dom构建它,但它不支持firefox。

If your don't want your CSS to affect your widget at all, you necessarily need to either: 如果您不希望CSS完全影响您的小部件,您必须要么:

  1. Overwrite each style manually for your widget, or 手动覆盖窗口小部件的每种样式,或
  2. Use an iframe 使用iframe

Using JavaScript for an iframe is allowed if your are under the same domain, which in this case wouldn't be a problem for you. 如果您位于同一个域下,则允许使用JavaScript作为iframe,在这种情况下,这对您来说不是问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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