Last active
December 16, 2015 09:28
-
-
Save mgarratt/5412892 to your computer and use it in GitHub Desktop.
Sass mixin to add an arrow to one side of a block Based on:
http://css-tricks.com/snippets/css/css-triangle/
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 arrow($direction, $colour, $size: 5px) { | |
position: relative; | |
&:before { | |
content: ''; | |
display: block; | |
position: absolute; | |
width: 0; | |
height: 0; | |
@if $direction == up { | |
top: -$size; | |
left: 50%; | |
margin-left: -($size/2); | |
border-left: $size solid transparent; | |
border-right: $size solid transparent; | |
border-bottom: $size solid $colour; | |
} @else if $direction == down { | |
bottom: -$size; | |
left: 50%; | |
margin-left: -($size/2); | |
border-left: $size solid transparent; | |
border-right: $size solid transparent; | |
border-top: $size solid $colour; | |
} @else if $direction == left { | |
top: 50%; | |
left: -$size; | |
margin-top: -($size/2); | |
border-top: $size solid transparent; | |
border-bottom: $size solid transparent; | |
border-right: $size solid $colour; | |
} @else if $direction == right { | |
top: 50%; | |
right: -$size; | |
margin-top: -($size/2); | |
border-top: $size solid transparent; | |
border-bottom: $size solid transparent; | |
border-left: $size solid $colour; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment