Skip to content

Instantly share code, notes, and snippets.

@killercup
Created September 6, 2013 12:49
Show Gist options
  • Save killercup/6463336 to your computer and use it in GitHub Desktop.
Save killercup/6463336 to your computer and use it in GitHub Desktop.
// ====== CSS ARROW PLEASE =====
// technique from http://cssarrowplease.com/
@mixin arrow-top($size, $color, $border-width, $border-color, $left: 50%) {
& {
background: $color;
border: 1px solid $border-color;
}
&:after, &:before {
bottom: 100%;
border: solid transparent;
content: " ";
height: 0;
width: 0;
position: absolute;
pointer-events: none;
}
&:after {
border-color: rgba($color, 0);
border-bottom-color: $color;
border-width: $size;
left: $left;
margin-left: -$size;
}
&:before {
border-color: rgba($border-color, 0);
border-bottom-color: $border-color;
border-width: $size + round(1.41421356 * $border-width);
left: $left;
margin-left: -($size + round(1.41421356 * $border-width));
}
}
@killercup
Copy link
Author

Currently just the top arrow as I needed that for a dropdown. Adding left, right and bottom is left as an exercise for the forker.

@nathanbedford
Copy link

Nice! Just pulled into my project. Thanks

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