Created
February 12, 2013 13:41
-
-
Save kogakure/4769950 to your computer and use it in GitHub Desktop.
SASS: Triangle Mixin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
for real? this is the worst mixin ever, sorry. it's not DRY at all.