Created
March 27, 2018 10:24
-
-
Save NitsanBaleli/6b435651ecaf701441bb630f2ae30253 to your computer and use it in GitHub Desktop.
css triangle
This file contains hidden or 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 equilateral-triangle($direction, $size, $color) { | |
| width: 0; | |
| height: 0; | |
| @if $direction == 'up' { | |
| border-left: em($size) solid transparent; | |
| border-right: em($size) solid transparent; | |
| border-bottom: em($size) solid $color; | |
| } | |
| @else if $direction == 'down' { | |
| border-left: em($size) solid transparent; | |
| border-right: em($size) solid transparent; | |
| border-top: em($size) solid $color; | |
| } | |
| @else if $direction == 'right' { | |
| border-top: em($size) solid transparent; | |
| border-bottom: em($size) solid transparent; | |
| border-left: em($size) solid $color; | |
| } | |
| @else if $direction == 'left' { | |
| border-top: em($size) solid transparent; | |
| border-bottom: em($size) solid transparent; | |
| border-right: em($size) solid $color; | |
| } | |
| } | |
| @function em($pixels, $context: 16px) { | |
| @return #{$pixels/$context}em; | |
| } | |
| .test { | |
| margin-top: 100px; | |
| height: 50px; | |
| width: 50px; | |
| border: 1px solid black; | |
| position: relative; | |
| &::before { | |
| content: ""; | |
| position: absolute; | |
| top: 0; | |
| transform: translateY(-100%) rotate(45deg); @include equilateral-triangle(up, 5px, red); } } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment