Skip to content

Instantly share code, notes, and snippets.

@GoodNew5
Created June 14, 2018 13:35
Show Gist options
  • Save GoodNew5/6ecd0df2b8d2dfc41112f2d5d529e362 to your computer and use it in GitHub Desktop.
Save GoodNew5/6ecd0df2b8d2dfc41112f2d5d529e362 to your computer and use it in GitHub Desktop.
triangle.scss
@mixin triangle($direction, $color, $height, $width) {
border-style: solid;
height: 0;
width: 0;
@if($direction == 'top') {
border-color: transparent transparent $color transparent;
border-width: 0 ($width/2) $height ($width/2);
}
@if ($direction == 'bottom') {
border-color: $color transparent transparent transparent;
border-width: $height ($width/2) 0 ($width/2);
}
@if ($direction == 'right') {
border-color: transparent transparent transparent $color;
border-width: ($height/2) 0 ($height/2) $width;
}
@if ($direction == 'left') {
border-color: transparent $color transparent transparent;
border-width: ($height/2) $width ($height/2) 0;
}
// Ordinal Directions - can be scalene this way!
@if ($direction == 'top-left') {
border-color: $color transparent transparent transparent;
border-width: $height $width 0 0;
}
@if ($direction == 'top-right') {
border-color: transparent $color transparent transparent;
border-width: 0 $width $height 0;
}
@if ($direction == 'bottom-left') {
border-color: transparent transparent transparent $color;
border-width: $height 0 0 $width;
}
@if ($direction == 'bottom-right') {
border-color: transparent transparent $color transparent;
border-width: 0 0 $height $width;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment