Skip to content

Instantly share code, notes, and snippets.

@rizkysyazuli
Last active February 20, 2020 16:14
Show Gist options
  • Save rizkysyazuli/5c1692362bf3aa75aad2 to your computer and use it in GitHub Desktop.
Save rizkysyazuli/5c1692362bf3aa75aad2 to your computer and use it in GitHub Desktop.
[SCSS - Positioning] #scss
@mixin position($position, $args) {
@each $o in top right bottom left {
$i: index($args, $o);
@if $i and $i + 1 <= length($args) and type-of(nth($args, $i + 1)) == number {
#{$o}: nth($args, $i + 1);
}
}
position: $position;
}
@mixin absolute($args) {
@include position("absolute", $args);
}
@mixin fixed($args) {
@include position("fixed", $args);
}
@mixin relative($args) {
@include position("relative", $args);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment