Skip to Content
Pragmatic Guide to Sass 3
book

Pragmatic Guide to Sass 3

by Hampton Lintorn Catlin, Michael Lintorn Catlin
July 2016
Intermediate to advanced
130 pages
2h 11m
English
Pragmatic Bookshelf
Content preview from Pragmatic Guide to Sass 3
8Keeping Code Clean with Mixins

Mixins are some of the more powerful elements of Sass. A mixin is a fragment of Sass that can easily be applied to another selector. Let’s say you require a distinct style for alerts: red text with small caps. You need to apply this style to many alerts in your document. You don’t want to have to repeat color: #AE2F2F; over and over again. This is the perfect situation for a mixin!

To define a mixin, all you need to type is @mixin, followed by the name of the mixin and then its styling.

Once you’ve defined it, you can easily use a mixin wherever you please—it’s a super-portable set of attributes. A mixin can include far more data than a simple variable. When you want to use the mixin, just type @include.

Mixins ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Jump Start Sass

Jump Start Sass

Hugo Giraudel, Miriam Suzanne
What Employees Want Most in Uncertain Times

What Employees Want Most in Uncertain Times

Kristine W. Powers, Jessica B.B. Diaz
Mastering Sass

Mastering Sass

Luke Watts

Publisher Resources

ISBN: 9781680502060Errata Page