Skip to content

Instantly share code, notes, and snippets.

@aolko
Forked from jondaiello/_arrows.scss
Created August 22, 2016 11:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aolko/620f9df767ae102202d01cd8c417720e to your computer and use it in GitHub Desktop.
Save aolko/620f9df767ae102202d01cd8c417720e to your computer and use it in GitHub Desktop.
SASS @mixin for Arrows
// Demo at http://codepen.io/jondaiello/full/YWRbOx/
/* This mixin is for generating CSS arrows on a box */
@mixin box-arrow($arrowDirection, $arrowColor, $arrowSize: 10px) {
position: relative;
z-index: 10;
&::after {
content: '';
width: 0;
height: 0;
display: block;
position: absolute;
z-index: 10;
border: 0;
@if $arrowDirection == bottom or $arrowDirection == top {
border-left: $arrowSize solid transparent;
border-right: $arrowSize solid transparent;
margin-left: -$arrowSize;
left: 50%;
@if $arrowDirection == bottom {
border-top: $arrowSize solid $arrowColor;
bottom: -$arrowSize;
}
@if $arrowDirection == top {
border-bottom: $arrowSize solid $arrowColor;
top: -$arrowSize;
}
}
@if $arrowDirection == left or $arrowDirection == right {
border-top: $arrowSize solid transparent;
border-bottom: $arrowSize solid transparent;
margin-top: -$arrowSize;
top: 50%;
@if $arrowDirection == left {
border-right: $arrowSize solid $arrowColor;
left: -$arrowSize;
}
@if $arrowDirection == right {
border-left: $arrowSize solid $arrowColor;
left: auto;
right: -$arrowSize;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment