What mixins are and how we can use them to easily produce oft-needed code
Nesting @extend
and placeholder
selectors are very convenient but they don't actually produce extra code. Mixins on the other hand do. Those readers who have been unfortunate enough to use Microsoft Word or Excel may have used macros. If so, think of mixins like macros.
Typically, a mixin is defined once, then included elsewhere in the Sass file and passed any optional arguments. Then, on compilation, it generates the relevant code.
That sounds pretty complicated and "programmer-ish". If such talk makes your palms go a little sweaty or your eyes glaze over, don't worry.
Compass has literally hundreds of ready-made mixins that address every conceivable CSS need. Don't want to ...
Get Sass and Compass for Designers now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.