Skip to content

Instantly share code, notes, and snippets.

@andi1984
Created May 2, 2014 09:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andi1984/b32b7c3a2e10577c92b7 to your computer and use it in GitHub Desktop.
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/)
@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