简体   繁体   English

引导程序可以用于网站插件而不会与网站样式和js冲突吗?

[英]Can bootstrap be used for website plugins without conflicting with site styles and js?

Take a website, a CMS, or anything. 以网站,CMS或其他任何方式。 I want to develop a plugin, or a module basically... but I want to use Bootstrap for the CSS and the javascript components that it offers. 我想开发一个插件,或者基本上是一个模块...但是我想将Bootstrap用于CSS及其提供的javascript组件。

I've heard about namespacing, but does anyone know if this is possible with the JS functionality of bootstrap as well? 我听说过命名空间,但是有人知道引导区的JS功能是否也可以做到?

There could be a ton of different scenarios at play, so just trying to figure out the best way to handle it. 可能会有很多不同的场景在起作用,所以只是尝试找出处理它的最佳方法。

You could do this if your plugin would be in a separate iframe. 如果您的插件位于单独的iframe中,则可以执行此操作。

Another wrong way would be to add a class to that plugin outer element and prefix every Bootstrap CSS rule with that class. 另一个错误的方法是在该插件的外部元素中添加一个类,并为每个Bootstrap CSS规则添加该类的前缀。 (I wouldn't do that) (我不会那样做)

In HTML5 the style scope attribute was introduced. 在HTML5中,引入了样式范围属性 This feature would solve your problem but it is not really supported yet in all major browsers. 此功能可以解决您的问题,但并非所有主流浏览器都支持此功能。

You could try jQuery Scoped CSS Plugin which should add support for the above HTML5 feature. 您可以尝试使用jQuery范围CSS插件 ,该插件应添加对上述HTML5功能的支持。

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

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