Created
March 22, 2017 02:47
-
-
Save micjamking/c6c020259fd7e36fc8af5d524247ee78 to your computer and use it in GitHub Desktop.
Sass Triangle Shape 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
/** | |
* Triangle CSS Shape | |
* https://css-tricks.com/examples/ShapesOfCSS/ | |
* @usage @include triangle('down', 10px, #111) | |
*/ | |
@mixin triangle ($direction: 'up', $size: 100px, $color: red){ | |
width: 0; | |
height: 0; | |
@if $direction == 'up' { | |
border-left: ($size / 2) solid transparent; | |
border-right: ($size / 2) solid transparent; | |
border-bottom: $size solid $color; | |
} | |
@else if $direction == 'down' { | |
border-left: ($size / 2) solid transparent; | |
border-right: ($size / 2) solid transparent; | |
border-top: $size solid $color; | |
} | |
@else if $direction == 'left' { | |
border-top: ($size / 2) solid transparent; | |
border-right: $size solid $color; | |
border-bottom: ($size / 2) solid transparent; | |
} | |
@else if $direction == 'right' { | |
border-top: ($size / 2) solid transparent; | |
border-left: $size solid $color; | |
border-bottom: ($size / 2) solid transparent; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment