Css / Sass
All Except Last Child Selector
1 2 3 |
|
Centering
See http://css-tricks.com/centering-css-complete-guide
Extend in Sass
Given the example from the sass documentation, given this sass:
1 2 3 4 5 6 7 8 |
|
its compiled css is:
1 2 3 4 5 6 7 8 |
|
Note that the styles are comma separated, decreasing the amount of duplicate code (rather than re-rendering each style inside the .seriousError
selector). This can lead to some unintended behavior:
– If you extend another selector, selectors nested under the original are also extended
– You cannot extend a selector which is nested, eg – @extend div span
will not work
As a rule of thumb, you can use @extend
instead of including a @include a_mixin
when there are no arguments to be passed. Use caution when the selector you’re extending from has nested selectors though.
Color Functions in Sass
This link has a list of all of them. Notably:
lighten($color, $amount) – Makes a color lighter
darken($color, $amount) – Makes a color darker
grayscale($color) – Converts a color to grayscale
complement($color) – Returns the complement of a color
invert($color) – Returns the inverse of a color
Each loops in Sass
From the sass documentation:
1 2 3 4 5 |
|
For loops in Sass
From the sass documentation:
1 2 3 |
|
Mixins in Sass
The sass documentation has a good example that demonstrates mixins:
1 2 3 4 5 6 7 8 9 |
|
is compiled to:
1 2 3 4 5 6 7 8 9 10 11 |
|
Mixins also support keyword arguments, so you can explicitly name the parameters in the @include
statement and include them out of order. Here’s an example that works with the sexy-border
mixin above:
1
|
|
Placeholder Selectors in Sass
Placeholder selectors can only be used with the @extend
directive. If they’re not referenced at all, they render no output in the compiled css.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
|
is compiled to:
1 2 3 4 5 6 7 8 |
|
While loop in Sass
From the sass documentation:
1 2 3 4 5 |
|
Watching a Sass File
Automatically recompiles scss into css:
1
|
|