Skip to content

Instantly share code, notes, and snippets.

@evuez
Last active August 29, 2015 14:10
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 evuez/3652852181d97e4cd79d to your computer and use it in GitHub Desktop.
Save evuez/3652852181d97e4cd79d to your computer and use it in GitHub Desktop.
Responsive triangle mixin (up / down)
// Triangle
@mixin triangle($dir, $size: 50%, $color: currentcolor) {
$base: null;
@if $dir == 'up' {
$base: bottom;
}
@else if $dir == 'down' {
$base: top;
}
position: absolute;
width: $size;
height: $size * 1.6;
left: (100% - $size) / 2;
padding-left: $size / 2;
padding-#{$base}: $size / 2;
overflow: hidden;
&::after {
content: '';
display: block;
width: 0;
height: 0;
margin-left: -500px;
@if $dir == 'down' {
margin-top: -500px;
}
border-left: 500px solid transparent;
border-right: 500px solid transparent;
border-#{$base}: 500px solid $color;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment