Skip to content

Instantly share code, notes, and snippets.

@houkanshan
Created February 4, 2013 13:07
Show Gist options
  • Save houkanshan/4706645 to your computer and use it in GitHub Desktop.
Save houkanshan/4706645 to your computer and use it in GitHub Desktop.
A CodePen by MieMie. Hexagon image - css3 + html
div.box
div.inner1
div.inner2
@import "compass"
$boxHeight: 110px
$boxWidth: $boxHeight * 1.732 // sqrt(3)
$imageUrl: "http://img3.douban.com/view/photo/photo/public/p462657443.jpg"
.box
position: relative
@extend %box
background: url($imageUrl) no-repeat
.inner1
@extend %box
@extend %inner
-webkit-transform: rotate(60deg)
&:after
-webkit-transform: rotate(-60deg) translate(- $boxWidth/2, 0px)
.inner2
@extend %box
@extend %inner
-webkit-transform: rotate(-60deg)
&:after
-webkit-transform: rotate(60deg) translate(0, - ($boxHeight*3/2))
%box
height: $boxHeight
width: $boxWidth
background-position: 50% 50%
%inner
z-index: -1
position: absolute
background: inherit
overflow: hidden
&:after
height: 2 * $boxHeight
width: $boxWidth
content: ''
position: absolute
left: 0
top: 0
-webkit-transform-origin: 0 0
z-index: 0
background: inherit
// position
body, html
height: 100%
width: 100%
.box
top: 45%
left: 45%
// position end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment