Skip to content

Instantly share code, notes, and snippets.

@kieranmv95
Last active April 27, 2018 04:11
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save kieranmv95/cc4b711f86981469f06bff2d6c674004 to your computer and use it in GitHub Desktop.
Save kieranmv95/cc4b711f86981469f06bff2d6c674004 to your computer and use it in GitHub Desktop.
Create pure CSS triangles in a matter of seconds with this scss mixin
/*
Kieran Venison scss mixin
kieranmv95@gmail.com
Example usage: http://codepen.io/Kieranmv95/pen/QNYLvE
*/
// Name: Arrow
// Params: direction, color, size
@mixin arrow($arrow-direction, $arrow-color, $arrow-size){
//Generic settings
width: 0;
height: 0;
display: inline-block;
//Arrow main statement
@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('right', orange, 30px);}
.down {@include arrow('down',black,30px);}
.up {@include arrow('up', blue, 60px);}
.left {@include arrow('left',red,10px);}
@kieranmv95
Copy link
Author

Improvements Welcome :)

@Kane1994
Copy link

Kane1994 commented May 6, 2016

Tried running straight in Codepen.
================== ISSUE FIXED ==================

"Properties are only allowed within rules, directives, mixin includes, or other properties."

New codepen: http://codepen.io/Kieranmv95/pen/QNYLvE

@lepryko
Copy link

lepryko commented May 6, 2016

@Kane1994

================== ISSUE FIXED ==================

example at the bottom not working because they are not in divs

@kieranmv95
Copy link
Author

Updated gist with new map setting and added functional example for you :)

@kieranmv95
Copy link
Author

Remove all the map rubbish, was over-complicating something that should be simple

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment