Last active
July 29, 2019 09:20
-
-
Save alcidesqueiroz/323fbf9ebbd9ff1834f7 to your computer and use it in GitHub Desktop.
Sass: Mixin to assign the same value to multiple properties at once
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@mixin same($values...) { | |
$length: length($values); | |
$value: nth($values, $length); | |
@for $i from 1 to $length { | |
#{nth($values, $i)}: $value; | |
} | |
} | |
// Usage: | |
footer { | |
@include same(top, left, right, bottom, 0); | |
@include same(height, line-height, 60px); | |
} | |
// Output | |
footer { | |
top: 0; | |
left: 0; | |
right: 0; | |
bottom: 0; | |
height: 60px; | |
line-height: 60px; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Show, velho! :)