Limit the scope of bootstrap styles

后端 未结 9 2262
情歌与酒
情歌与酒 2020-11-27 02:56

How do I limit Bootstrap to just the scope of a div? I need to nest the Bootstrap stylesheet inside an ExtJS app for especific divs and both are clashing since they need the

9条回答
  •  南笙
    南笙 (楼主)
    2020-11-27 03:58

    Expanding on @Andrew Homeyer answer:

    I got scoped styling of boostrap working in my Reactjs app by doing the following:

    1. Went here and downloaded bootstrap source
    2. Followed the guide here to install grunt. summary:

    Bootstrap uses Grunt for its build system, with convenient methods for working with the framework. It's how we compile our code, run tests, and more.

    Installing Grunt: To install Grunt, you must first download and install node.js (which includes npm). npm stands for node packaged modules and is a way to manage development dependencies through node.js.

    Then, from the command line: Install grunt-cli globally with npm install -g grunt-cli. Navigate to the root /bootstrap/ directory, then run npm install. npm will look at the package.json file and automatically install the necessary local dependencies listed there. When completed, you'll be able to run the various Grunt commands provided from the command line.

    1. Edited the file less/bootstrap.less from the downloaded source to the following:

    .bootstrap-scope {...pasted all @imports here...}

    1. Ran grunt dist and copied the new dist folder into my project
      in App.js import './styling/bootstrap/css/bootstrap.min.css';.

    Similar discussion here

提交回复
热议问题