Created
May 2, 2014 09:22
-
-
Save andi1984/b32b7c3a2e10577c92b7 to your computer and use it in GitHub Desktop.
Mixin to generate triangles with borders (see http://css-tricks.com/snippets/css/css-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
@mixin triangle($direction:up, $hypotenuse-width:20px, $color:black) { | |
$triangle-border-width: $hypotenuse-width/2; | |
$triangleSettings: ( | |
up: ( | |
border-left: $triangle-border-width solid transparent, | |
border-right: $triangle-border-width solid transparent, | |
border-bottom: $triangle-border-width solid $color, | |
), | |
right: ( | |
border-top: $triangle-border-width solid transparent, | |
border-bottom: $triangle-border-width solid transparent, | |
border-left: $triangle-border-width solid $color, | |
), | |
down: ( | |
border-left: $triangle-border-width solid transparent, | |
border-right: $triangle-border-width solid transparent, | |
border-top: $triangle-border-width solid $color | |
), | |
left: ( | |
border-top: $triangle-border-width solid transparent, | |
border-bottom: $triangle-border-width solid transparent, | |
border-right: $triangle-border-width solid $color | |
) | |
); | |
width: 0; | |
height: 0; | |
@each $property, $value in map_get($triangleSettings,$direction) { | |
#{$property}: $value; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment