Created
June 14, 2018 13:35
-
-
Save GoodNew5/6ecd0df2b8d2dfc41112f2d5d529e362 to your computer and use it in GitHub Desktop.
triangle.scss
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($direction, $color, $height, $width) { | |
border-style: solid; | |
height: 0; | |
width: 0; | |
@if($direction == 'top') { | |
border-color: transparent transparent $color transparent; | |
border-width: 0 ($width/2) $height ($width/2); | |
} | |
@if ($direction == 'bottom') { | |
border-color: $color transparent transparent transparent; | |
border-width: $height ($width/2) 0 ($width/2); | |
} | |
@if ($direction == 'right') { | |
border-color: transparent transparent transparent $color; | |
border-width: ($height/2) 0 ($height/2) $width; | |
} | |
@if ($direction == 'left') { | |
border-color: transparent $color transparent transparent; | |
border-width: ($height/2) $width ($height/2) 0; | |
} | |
// Ordinal Directions - can be scalene this way! | |
@if ($direction == 'top-left') { | |
border-color: $color transparent transparent transparent; | |
border-width: $height $width 0 0; | |
} | |
@if ($direction == 'top-right') { | |
border-color: transparent $color transparent transparent; | |
border-width: 0 $width $height 0; | |
} | |
@if ($direction == 'bottom-left') { | |
border-color: transparent transparent transparent $color; | |
border-width: $height 0 0 $width; | |
} | |
@if ($direction == 'bottom-right') { | |
border-color: transparent transparent $color transparent; | |
border-width: 0 0 $height $width; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment