Skip to content

Instantly share code, notes, and snippets.

@zastrow
Last active January 18, 2019 13:38
Show Gist options
  • Save zastrow/6ccea07baa27ec97b53e to your computer and use it in GitHub Desktop.
Save zastrow/6ccea07baa27ec97b53e to your computer and use it in GitHub Desktop.
Simple Acute Triangle Mixin
// Triangle
@mixin triangle($position:"bottom", $color:"#000", $size:"1em", $opposite_size:"") {
$top: 0; $right: 0; $bottom: 0; $left: 0;
@if ( $position == "top" or $position == "bottom" ) {
$right: ($size/2) solid transparent;
$left: ($size/2) solid transparent;
@if ( $opposite_size != "" ) { $size: $opposite_size; }
@if ( $position == "top" ) {
$top: $size solid $color;
$bottom: 0 none;
}
@else if ( $position == "bottom" ) {
$top: 0 none;
$bottom: $size solid $color;
}
}
@if ( $position == "right" or $position == "left" ) {
$top: ($size/2) solid transparent;
$bottom: ($size/2) solid transparent;
@if ( $opposite_size != "" ) { $size: $opposite_size; }
@if ( $position == "right" ) {
$right: $size solid $color;
$left: 0 none;
}
@else if ( $position == "left" ) {
$right: 0 none;
$left: $size solid $color;
}
}
width: 0;
height: 0;
border-top: $top;
border-right: $right;
border-bottom: $bottom;
border-left: $left;
transform: rotate(360deg); // Smooths out the aliased edges
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment