Skip to content

Instantly share code, notes, and snippets.

@kogakure
Created February 12, 2013 13:41
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kogakure/4769950 to your computer and use it in GitHub Desktop.
Save kogakure/4769950 to your computer and use it in GitHub Desktop.
SASS: Triangle Mixin
@mixin triangle($width, $dir, $color) {
@if $dir == up {
width: 0;
height: 0;
border-left: $width/2 solid transparent;
border-right: $width/2 solid transparent;
border-bottom: $width/2 solid $color;
} @else if $dir == down {
width: 0;
height: 0;
border-left: $width/2 solid transparent;
border-right: $width/2 solid transparent;
border-top: $width/2 solid $color;
} @else if $dir == right {
width: 0;
height: 0;
border-top: $width solid transparent;
border-bottom: $width solid transparent;
border-left: $width solid $color;
} @else if $dir == left {
width: 0;
height: 0;
border-top: $width solid transparent;
border-bottom: $width solid transparent;
border-right: $width solid $color;
}
}
.triangle {
@include triangle(200px, up, #888);
}
@yairEO
Copy link

yairEO commented May 27, 2015

for real? this is the worst mixin ever, sorry. it's not DRY at all.

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