Skip to content

Instantly share code, notes, and snippets.

@rocbear
Last active September 4, 2015 12:27
Show Gist options
  • Save rocbear/a6c745a2d8b3695eae47 to your computer and use it in GitHub Desktop.
Save rocbear/a6c745a2d8b3695eae47 to your computer and use it in GitHub Desktop.
SCSS place something in the four corners of a container
$padding: 1em;
$positions: ("t", "l"), ("t", "r"), ("b", "r"), ("b", "l");
@each $v, $h in $positions {
#{".position-" + $v + $h} {
position: absolute;
top: if($v == "t", $padding, auto);
right: if($h == "r", $padding, auto);
bottom: if($v == "b", $padding, auto);
left: if($h == "l", $padding, auto);
}
}
/*
Outputs:
.position-tl { ...
.position-tr { ...
.position-br { ...
.position-bl { ...
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment