Hacker News new | ask | show | jobs
by kh_hk 4498 days ago
Be very wary, though, if you are using mixins to define these columns in a case-by-case basis, as this could lead to huge generated CSS (the properties of the column will be defined in each class the mixin has been used).
1 comments

Alternatively use SASS (and the bootstrap SASS port[1]) which doesn't has this problem, as it instead rewrites selectors.

i.e. if you have:

    .column {
      width: 100px;
      display: inline-block;
    }
And you do:

    .cool-sidebar {
      @extend .column;
    }
Then the generated css will be something like:

    .column, .cool-sidebar {
      width: 100px;
      display: inline-block;
    }
[1] https://github.com/twbs/bootstrap-sass
Thank you so much for pointing this out, Moretti! It drives me crazy when people talk about the extend feature like only SASS has it. People are always underestimating how similar Less and SASS are.
To be fair, Sass did have it about 3 years before LESS
Then, in Bootstrap terms and since the grid syntax is offered in mixins, should it be used as follows

    .foo-class {
        &:extend(.col-md-4, .col-md-offset-8)
    }
instead of using the mixin?

    .foo-class {
        make-md-column(4);
        make-md-column-offset(8);
    }
a rule of thumb I've been following when using Sass/LESS: If your mixin doesn't take arguments, you probably want `@extend`