Skip to content

Instantly share code, notes, and snippets.

@kogakure
Created February 12, 2013 13:41
Show Gist options
  • Select an option

  • Save kogakure/4769950 to your computer and use it in GitHub Desktop.

Select an option

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

yairEO commented May 27, 2015

Copy link
Copy Markdown

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