Last active
August 29, 2015 14:22
-
-
Save yairEO/946afffee17fe38d9aec to your computer and use it in GitHub Desktop.
SASS - MIXIN - Triangle
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 helper mixin (by Yair Even-Or) | |
// @param {Direction} $direction - Triangle direction, either `top`, `right`, `bottom` or `left` | |
// @param {Color} $color [currentcolor] - Triangle color | |
// @param {Length} $size [1em] - Triangle size | |
@mixin triangle($direction, $color: currentcolor, $size: 1em) { | |
$size: $size/2; | |
$transparent: rgba($color, 0); | |
$opposite: (top:bottom, right:left, left:right, bottom:top); | |
content: ''; | |
display: inline-block; | |
width: 0; | |
height: 0; | |
border: $size solid $transparent; | |
border-#{map-get($opposite, $direction)}-color: $color; | |
margin-#{$direction}: -$size/2; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
playground: http://jsbin.com/mipomevino/2/edit