Skip to content

Instantly share code, notes, and snippets.

@yairEO
Last active August 29, 2015 14:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yairEO/946afffee17fe38d9aec to your computer and use it in GitHub Desktop.
Save yairEO/946afffee17fe38d9aec to your computer and use it in GitHub Desktop.
SASS - MIXIN - Triangle
// Triangle helper mixin (by Yair Even-Or)
// @param {Direction} $direction - Triangle direction, either `top`, `right`, `bottom` or `left`
// @param {Color} $color [currentcolor] - Triangle color
// @param {Length} $size [1em] - Triangle size
@mixin triangle($direction, $color: currentcolor, $size: 1em) {
$size: $size/2;
$transparent: rgba($color, 0);
$opposite: (top:bottom, right:left, left:right, bottom:top);
content: '';
display: inline-block;
width: 0;
height: 0;
border: $size solid $transparent;
border-#{map-get($opposite, $direction)}-color: $color;
margin-#{$direction}: -$size/2;
}
@yairEO
Copy link
Author

yairEO commented May 27, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment