Created
June 12, 2015 22:20
-
-
Save gaintsev/112d4f6cf11e563dbe46 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
/* | |
* $direction - top, right, bottom or left | |
* $width - arrow width | |
* $height - arrow height | |
* $color - any color | |
* --- | |
* Inspired by: http://apps.eky.hk/css-triangle-generator/ | |
*/ | |
@mixin triangle($direction, $width, $height, $color) { | |
width: 0; | |
height: 0; | |
border-style: solid; | |
@if $direction == top { | |
border-width: 0 $width/2 $height $width/2; | |
border-color: transparent transparent $color transparent; | |
} @else if $direction == top { | |
border-width: $height/2 0 $height/2 $width; | |
border-color: transparent transparent transparent $color; | |
} @else if $direction == bottom { | |
border-width: $height $width/2 0 $width/2; | |
border-color: $color transparent transparent transparent; | |
} @else { | |
border-width: $height/2 $width $height/2 0; | |
border-color: transparent $color transparent transparent; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment