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
25Looping Through Maps

You can loop through maps in much the same way you loop through lists. You can use the @each function to go through a map. When looping through maps, much like lists, Sass starts at the beginning of the declaration—so order matters.

When using @each with maps, you have to pass in two variables—the key and the value. Here, there’s a map that consists of a series of widths of a hero image. These will make the hero image more responsive.

When looping through the $hero-widths, you must create variables for the key (in this case, $size) and the value (in this case, $width). You can then use these variables as necessary. In this case, there’s a series of classes that dictate the width of the hero image.

Another handy way ...

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