Skip to content

Instantly share code, notes, and snippets.

@bratsche
Created May 9, 2012 15:32
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 bratsche/2645575 to your computer and use it in GitHub Desktop.
Save bratsche/2645575 to your computer and use it in GitHub Desktop.
sass mixin for adding arrows to a div
$defaultBorder: none
=arrow($direction, $size, $color, $border: $defaultBorder)
position: relative
border: $border
&:after, &:before
@if $direction == top
bottom: 100%
@else if $direction == right
left: 100%
@else if $direction == bottom
top: 100%
@else if $direction == left
right: 100%
border: solid transparent
content: " "
height: 0
width: 0
position: absolute
pointer-events: none
&:after
@if $direction == top
border-bottom-color: $color
right: 50%
margin-left: -$size - 6px
@else if $direction == right
border-left-color: $color
bottom: 50%
margin-top: -$size - 6px
@else if $direction == bottom
border-top-color: $color
left: 50%
margin-left: -$size - 6px
@else if $direction == left
border-right-color: $color
top: 50%
margin-top: -$size - 6px
border-width: $size
border-width: $size + 6px
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment