Created
September 27, 2013 18:46
-
-
Save milcktoast/6733356 to your computer and use it in GitHub Desktop.
Position mixin
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 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