Skip to content

Instantly share code, notes, and snippets.

@captDaylight
Created December 10, 2015 22:48
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save captDaylight/3aa76d51252648954a31 to your computer and use it in GitHub Desktop.
Save captDaylight/3aa76d51252648954a31 to your computer and use it in GitHub Desktop.
Generate css arrows on any box. Example at http://codepen.io/captDaylight/pen/MKwzLW?editors=110 Based off of http://cssarrowplease.com/
// ARROW GENERATOR
@mixin arrow(
$box-edge: top,
$arrow-size: 10px,
$border-width: 4px,
$background-color: white,
$border-color: black) {
position: relative;
background: $background-color;
border: $border-width solid $border-color;
$box-edge-inverse: bottom;
$offset: left;
@if $box-edge == right { $box-edge-inverse: left; $offset: top; }
@else if $box-edge == bottom { $box-edge-inverse: top; $offset: left; }
@else if $box-edge == left { $box-edge-inverse: right; $offset: top; }
&:after, &:before {
#{$box-edge-inverse}: 100%;
#{$offset}: 50%;
border: solid transparent;
content: " ";
height: 0;
width: 0;
position: absolute;
pointer-events: none;
}
&:after {
border-color: rgba(136, 183, 213, 0);
border-#{$box-edge-inverse}-color: $background-color;
border-width: $arrow-size;
margin-#{$offset}: -$arrow-size;
}
&:before {
$border-offset: $arrow-size + round($border-width * 1.41421);
border-color: rgba(194, 225, 245, 0);
border-#{$box-edge-inverse}-color: $border-color;
border-width: $border-offset;
margin-#{$offset}: -$border-offset;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment