Created
August 16, 2013 16:57
-
-
Save tinkertrain/6251588 to your computer and use it in GitHub Desktop.
Offset mixing by Hugo Giraudel http://hugogiraudel.com/2013/08/05/offsets-sass-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($position, $args) { | |
$offsets: top right bottom left; | |
@each $o in $offsets { | |
$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 triplet calling the private mixin | |
* with the appropriate position value | |
*/ | |
@mixin absolute($args) { | |
@include _position(absolute, $args); | |
} | |
@mixin relative($args) { | |
@include _position(relative, $args); | |
} | |
@mixin fixed($args) { | |
@include _position(fixed, $args); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment