Skip to content

Instantly share code, notes, and snippets.

@branneman
Last active April 5, 2016 15:27
Show Gist options
  • Save branneman/9248961 to your computer and use it in GitHub Desktop.
Save branneman/9248961 to your computer and use it in GitHub Desktop.
[Sass] Mixin to provide short-hand positioning syntax
//
// Mixin to provide short-hand positioning syntax
// https://gist.github.com/branneman/9248961
//
// Usage:
// @include position(0 false 0 20rem);
// @include position(absolute, 0 false 0 20rem);
//
@mixin position ($position: relative, $coordinates: 0 0 0 0) {
@if type-of($position) == list {
$coordinates: $position;
$position: relative;
}
$top: nth($coordinates, 1);
$right: nth($coordinates, 2);
$bottom: nth($coordinates, 3);
$left: nth($coordinates, 4);
position: $position;
@if $top != false {
top: $top;
}
@if $right != false {
right: $right;
}
@if $bottom != false {
bottom: $bottom;
}
@if $left != false {
left: $left;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment