如何防止 Bootstrap 干扰自定义插件中的 WordPress 主题和默认 CSS?
我正在创建一个 WordPress 插件,并且需要 Bootstrap。我正在使用 Bootstrap CDN。
更具体地说,我不想更改 CSS 中的代码 我的插件是通过短代码切换的,所以我不能只定位单个页面
wp_register_style( 'bootstrap-css','https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css');
wp_enqueue_style('bootstrap-css');
,但问题是它会干扰我的 WordPress CSS(主题,标题等..) 有人知道如何解决吗?
I'm creating a WordPress plugin and I need Bootstrap. I'm using the Bootstrap CDN.
To be more specific, I don't want to change code in the CSS
And my plugin is toggled by a shortcode so I can't just target a single page
wp_register_style( 'bootstrap-css','https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css');
wp_enqueue_style('bootstrap-css');
But the problem is it interfere with my wordpress css (theme , title etc..)
Someone know how to resolve that ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要更改 CSS。您不能指望您的插件用户将 Bootstrap 加载到任何随机主题中,否则他们将面临与您完全相同的问题。另外,Bootstrap 对于一个插件来说有点重。不管怎样,你可能想要一个大大简化的版本。
ws_
。You'll need to change the CSS. You can't expect your plugin users to load Bootstrap into any random theme or they'll face the exact problems you are. Also, Bootstrap is a bit heavy for a plugin. You probably want a vastly reduced version of it anyway.
ws_
.