Skip to content

Instantly share code, notes, and snippets.

@jhonnymoreira
Last active August 29, 2015 14:19
Show Gist options
  • Save jhonnymoreira/59fa33f9bf774243d78a to your computer and use it in GitHub Desktop.
Save jhonnymoreira/59fa33f9bf774243d78a to your computer and use it in GitHub Desktop.
Simple Sass mixing to add shorthand (and specific) padding while converting units to 'rem' with the Bourbon function rem().
@mixin pad($paddings, $shorthand: true) {
$orientations: top right bottom left;
@if $shorthand {
@each $value in $paddings {
$paddings: set-nth($paddings, index($paddings, $value), rem($value));
}
padding: $paddings;
} @else {
@for $i from 1 through length($paddings) {
@if nth($paddings, $i) != x {
padding-#{nth($orientations, $i)}: rem(nth($paddings, $i));
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment