Skip to content

Instantly share code, notes, and snippets.

@iconifyit
Last active June 20, 2019 11:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iconifyit/e58e06a8d6a2564648eaff8a7ceb1b3a to your computer and use it in GitHub Desktop.
Save iconifyit/e58e06a8d6a2564648eaff8a7ceb1b3a to your computer and use it in GitHub Desktop.
SASS : Dynamically Build Ruleset
@mixin layout($sections, $unit:"%") {
#content {
@each $name, $rules in $sections {
.#{$name} {
@each $key, $value in $rules {
#{$key} : $value
}
}
}
}
}
$sections: (
header: (width: 100%, background: #aaa),
sidebar: (width: 33%, background: #ccc),
body: (width: 67%, background: #ddd),
footer: (width: 100%, background: #bbb)
);
@include layout($sections)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment