Skip to content

Instantly share code, notes, and snippets.

@nex3
Forked from tj/out.css
Created January 31, 2011 23:52
Show Gist options
  • Save nex3/805090 to your computer and use it in GitHub Desktop.
Save nex3/805090 to your computer and use it in GitHub Desktop.
body {
foo: bottom;
foo: right;
foo: bottom right;
}
@function opposite-position($pos)
@if $pos == top
@return bottom
@else if $pos == bottom
@return top
@else if pos == left
@return right
@else if pos == right
@return left
@else
@warn 'Invalid position ' + pos
@return none
@function opposite($positions)
$ret: ()
@each $pos in $positions
$pos: opposite-position(pos)
$ret: if(length($ret) == 0, $pos, join($ret, $pos))
body
foo: opposite(top)
foo: opposite(left)
foo: opposite(top left)
opposite-position(pos)
if pos == top
bottom
else if pos == bottom
top
else if pos == left
right
else if pos == right
left
else
error('Invalid position ' + pos)
opposite(positions)
for pos in positions
pos = opposite-position(pos)
ret = ret is defined ? ret pos : pos
body
foo opposite(top)
foo opposite(left)
foo opposite(top left)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment