Select your elements with SASS and let this selector inherit the style of a Bootstrap class.
body > div > div {
@extend .col-xs-4;
}
But I never tried to use it that way.Select your elements with SASS and let this selector inherit the style of a Bootstrap class.
body > div > div {
@extend .col-xs-4;
}
But I never tried to use it that way.This might seem like an obvious thing to generate cleaner and more 'semantic' markup but you will end up with tight coupling all over the place. When you change anything in your layout you'll need to rewrite parts of your css, which is basically twice the effort. You'll just end up wasting your employers time and money.
If you want some deeper insight into why it's considered a bad philosophy, I highly recommend reading some articles by Harry Roberts.
Then again, some succesful professionals actually work this way, I know a few.
.home { .twitter-area { @include grid-column(4); } }
But personally I find that to be much more of a pain in the butt to come back to a couple of months later than just applying the column classes directly to elements.
I don't recall saying anything about inline css though. To be specific, I'm saying that I prefer to have the column classes directly applied to the elements as opposed to using sass to include the column css to the semantic CSS classes of the elements.
I dunno what that has to do with applying a style attribute directly inline to an element.
I'll tell you what doe bug me, when I change the number of columns on my project, becasue that is coded directly into the elements, but honestly I've never had to do that very far into any project.
But it somehow hurts to look at the markup later, with all the classes, etc.
But practically I find that it's less difficult to make layout changes this way-- I can just cut sections and paste them somewhere else and I don't have to look elsewhere for their actual layout rules. I find it much more difficult to untangle the grid system when I can look at the classes directly on the elements.
I say this having had to do it even for my own code quite a bit... I just find it a little more difficult to think out when I don't have the columns listed on the elements themselves.
@import 'bootstrap/variables';
@import 'bootstrap/normalize';
@import "bootstrap/mixins/clearfix";
@import "bootstrap/mixins/grid";
@import "bootstrap/mixins/grid-framework";
and then you can insert it: article {
@include make-sm-column(5);
@include make-sm-column-offset(1);
@include make-xs-column(6);
}I just found it faster to add the classes directly to the HTML.
But I will check how this would work with Babel+WebPack+React in the future.
I can import SASS files in JS, but they would have to be merged with the Bootstrap SASS etc.