Skip to content

Instantly share code, notes, and snippets.

@wmeredith
Forked from kieranmv95/_arrow.scss
Last active May 6, 2016 15:57
Show Gist options
  • Save wmeredith/b4eba24d842ec5a2fbd074682b534bb5 to your computer and use it in GitHub Desktop.
Save wmeredith/b4eba24d842ec5a2fbd074682b534bb5 to your computer and use it in GitHub Desktop.
Create pure CSS triangles in a matter of seconds with this scss mixin
@mixin arrow($settings){
$arrow-direction: map-get($settings, direction);
$arrow-color: map-get($settings, color);
$arrow-size: map-get($settings, size);
width: 0;
height: 0;
display: inline-block;
@if ($arrow-direction == down){
border-left: $arrow-size solid transparent;
border-right: $arrow-size solid transparent;
border-top: $arrow-size solid $arrow-color;
} @else if ($arrow-direction == up) {
border-left: $arrow-size solid transparent;
border-right: $arrow-size solid transparent;
border-bottom: $arrow-size solid $arrow-color;
} @else if ($arrow-direction == left){
border-top: $arrow-size solid transparent;
border-bottom: $arrow-size solid transparent;
border-right: $arrow-size solid $arrow-color;
} @else if ($arrow-direction == right){
border-top: $arrow-size solid transparent;
border-bottom: $arrow-size solid transparent;
border-left: $arrow-size solid $arrow-color;
}
}
//EXAMPLE USAGE
.right {
@include arrow((
direction: 'right',
color: orange,
size: 30px
));
}
.down {
@include arrow((
direction: 'down',
color: black,
size: 30px
));
}
.up {
@include arrow((
direction: 'up',
color: blue,
size: 60px
));
}
.left {
@include arrow((
direction: 'left',
color: red,
size: 10px
));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment