June 2025
Beginner
817 pages
31h 30m
English
Besides variables, mixins represent the most commonly used feature of Sass. Mixins are entire blocks of CSS features you can reuse as a whole at any time. Creating and using them is just as easy. To define a mixin, you want to follow these steps:
@mixin mixin-name { ...}
As usual, you need to write your CSS features between curly brackets. Then, you can use @include to access this code block at any time:
@include mixin-name;
For this purpose, we’ll use our previous example from this chapter with mixins (see Table 16.6).
|
SCSS File |
CSS File |
|---|---|
|
...@mixin article-style { background-color: $color-primary; color: $color-primary-font; padding: 0.1em; margin-bottom: $spacing-std; border-radius: 5px; ... |
Read now
Unlock full access