I was not satisfied with any of these answers. Using Less to cover the rules created all kinds of defects. Clearfix, for example, has been corrupted. And rules like button.close became button.bootstrap close instead of what I really wanted: .bootstrap button.close .
I used a different approach. I use PostCSS to handle the finished CSS that comes with Bootstrap. I use the Scopify plugin to span each rule with .bootstrap .
This is mostly happening. Of course, there are html and body rules that become .bootstrap html and .bootstrap body that become insensitive. Don't worry ... I can just write a PostCSS transformation to clear them:
var elevateGlobalsPlugin = postcss.plugin('elevateGlobals', function(opts) { return function(css, result) { css.walkRules(function(rule) { rule.selector = rule.selector.replace('.bootstrap html', '.bootstrap'); rule.selector = rule.selector.replace('.bootstrap body', '.bootstrap'); }); } });
Now I can highlight all Bootstrap styles by adding class="bootstrap" at the top level.
Brian Genisio Jan 25 '16 at 21:21 2016-01-25 21:21
source share