Skip to content

Instantly share code, notes, and snippets.

@milcktoast
Created September 27, 2013 18:46
Show Gist options
  • Save milcktoast/6733356 to your computer and use it in GitHub Desktop.
Save milcktoast/6733356 to your computer and use it in GitHub Desktop.
Position mixin
@mixin position ($pos: relative, $coords: 0 0 0 0) {
@if type-of($pos) == list {
$coords: $pos;
$pos: relative;
}
$length: length($coords);
position: $pos;
@if $length > 0 { top: nth($coords, 1); }
@if $length > 1 { right: nth($coords, 2); }
@if $length > 2 { bottom: nth($coords, 3); }
@if $length > 3 { left: nth($coords, 4); }
}
// Usage
// -----
@include position(absolute, 10px 0 0 0);
@include position(10px);
@include position(null null 10px);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment