Last active
August 29, 2015 14:17
-
-
Save rgkimball/a2e357bb11597f4f8f3a to your computer and use it in GitHub Desktop.
This is an extremely lightweight mixin for adding CSS triangles to pseudo elements.
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: "right", $size: 5px, $color: '#FFFFFF') { | |
@if not index(top right bottom left, $direction) { | |
@warn "\"#{$direction}\" is not a valid direction value. Value must be one of: top, right, bottom, left"; | |
} | |
@else { | |
@include transform(scale(1.01)); // @see https://brettstrikesback.com/de-pixelating-the-css-triangle/ | |
border: $size solid transparent; | |
border-#{$direction}-color: $color; | |
border-#{opposite-position($direction)}-width: 0; | |
#{opposite-position($direction)}: -$size; | |
content: ''; | |
height: 0; | |
width: 0; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment