Lurker News

Comments (161) 45 threads

Show all comments

Showing thread 3 of 45

matt40773 replies#
I feel like bootstrap has become the jquery of css themes. People will launch into a lecture on "separation of concerns" when they see a style attribute in html or a ruby loop in an .erb template. Yet they litter their code with class="col-xs-4" without a second thought.
ThomPete1 reply#
Whats the problem with that? Honest question.
blaze331 reply#
From what I recall css class names should be semantic because they're in the html code and should relate to the content and not to its current presentation. So class="col-xs-4" is unsemantic.

Just searched for "semantic name" and found this article from 2011 that explain the subject quite well: https://css-tricks.com/semantic-class-names/

ThomPete1 reply#
Couldn't that be changed in the Bootstrap source code easily?

Continue this thread — 1 reply

k__5 replies#
I heard it can be used differently.

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.
lorddoig1 reply#
I (try) to use it this way wherever practicable. There are caveats and gotchas but in general it works as expected.
k__2 replies#
Nice to know.

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.

Continue this thread — 2 replies

scarecrowbob2 replies#
Well, typically it's more like:

.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.

k__1 reply#
Same here.

But it somehow hurts to look at the markup later, with all the classes, etc.

Continue this thread — 1 reply

usaphp1 reply#
And then in case you want to change element size you will have to go through all the elements that were generated in the backend where you applied inline style and change that manually for each of them? You either have never worked with big CSS projects or I am just not understanding what you mean, applying inline styles directly to elements will cause a maintenance havoc in my opinion

Continue this thread — 1 reply

antidaily#
I do. It's great. It's the best grid IMO. Here's all you need:

  @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);
    }
damptowel#
As someone who did a couple of front end jobs both building and fixing css built in this way I can give you one advice: don't.

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.

encoderer#
HTML is markup and that class name is a declarative way of saying "this is 4 columns wide on phone sized screens".

I don't see the problem.