Skip to content

Instantly share code, notes, and snippets.

@leahtard
Last active April 26, 2016 17:26
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 leahtard/a6aad62088798679f220dc2232e9e3bb to your computer and use it in GitHub Desktop.
Save leahtard/a6aad62088798679f220dc2232e9e3bb to your computer and use it in GitHub Desktop.
Sass hexagon mixin. Inspired by http://csshexagon.com/
@mixin hexagon($color: #333, $size: 200)
position: relative
width: $size + unquote("px")
height: $size * 0.577 + unquote("px")
background-color: $color
margin: $size * 0.288 + unquote("px") 0
&:before, &:after
content: ""
position: absolute
left: 0
width: 0
border-left: $size * 0.5 + unquote("px") solid transparent
border-right: $size * 0.5 + unquote("px") solid transparent
&:before
bottom: 100%
border-bottom: $size * 0.288 + unquote("px") solid $color
&:after
top: 100%
width: 0
border-top: $size * 0.288 + unquote("px") solid $color
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment