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
17Manipulating @content

Mixins can have full declaration blocks passed into them when they are included. When declaring the mixin, you can include the content that’s passed in by using the @content directive.

This is useful for some complex mixins and libraries. It isn’t used that often, but you can build some clever and useful mixins with it.

In the example, you want to style the page slightly differently if the summer sales attribute is on the body. You don’t want to have to type out that long, ungainly selector every time you want to make a small adjustment to the styles. This is a perfect situation for passing in a content block! You can see in the mixin declaration that there’s also an & to indicate the body rule should be at the top ...

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