Skip to content

Instantly share code, notes, and snippets.

@kflorence
Created April 2, 2012 23:28
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 kflorence/2287980 to your computer and use it in GitHub Desktop.
Save kflorence/2287980 to your computer and use it in GitHub Desktop.
@mixin arrow($color, $width)
/*
HTML: <img class="arrow" src="<?= $wg->BlankImgUrl ?>" />
SASS: .arrow { @include arrow(); }
*/
@mixin arrow($width: 4px, $color: black, $direction: 'down') {
border-color: transparent;
// Fixes the 'jagged line' problem for modern browsers
// See: http://css-tricks.com/snippets/css/css-triangle/#comment-108252
border-color: rgba($color, 0);
border-width: $width;
// Fixes the 'thin stroke of grey' on border edges in Firefox
// See: http://css-tricks.com/snippets/css/css-triangle/#comment-103509
border-style: inset;
height: 0;
// Center vertically with the surrounding line
vertical-align: middle;
width: 0;
@if ($direction == 'down') {
border-bottom: 0;
border-top-color: $color;
border-top-style: solid;
} @else if ($direction == 'left') {
border-left: 0;
border-right-color: $color;
border-right-style: solid;
} @else if ($direction == 'right') {
border-left-color: $color;
border-left-style: solid;
border-right: 0;
} @else if ($direction == 'up') {
border-bottom-color: $color;
border-bottom-style: solid;
border-top: 0;
}
}
@kflorence
Copy link
Author

Todo: apply to img only. Don't use classes for directions, use a param.

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