Created
February 12, 2013 12:45
-
-
Save davidhund/4762637 to your computer and use it in GitHub Desktop.
A rotated hexagon with CSS only
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* A rotated hexagon with CSS only | |
*/ | |
body { | |
background: #f06; | |
background: linear-gradient(45deg, #CFF, #3FF); | |
color: #FFF; | |
min-height: 100%; | |
} | |
.hexagon, | |
.hexagon__inner { | |
width: 300px; | |
height: 300px; | |
padding: 0; | |
text-align: center; | |
line-height: 300px; | |
font-size: 64px; | |
border-radius: 50%; | |
} | |
body:hover .hexagon, | |
body:hover .hexagon__inner { | |
border-radius: 20%; | |
} | |
.hexagon { | |
margin: 2em auto; | |
position: relative; | |
transform-style: preserve-3d; | |
transform: rotate(-90deg) rotateY(45deg) rotateX(45deg); | |
background-color: rgba(0,0,0,0.2); | |
} | |
.hexagon__inner | |
{ | |
display: block; | |
content: ""; | |
position: absolute; | |
background: rgba(0,0,0,0.2); | |
} | |
.hexagon__inner.one { | |
-webkit-transform: rotateY(90deg) translateZ(150px); | |
} | |
.hexagon__inner.two { | |
-webkit-transform: translateZ(150px); | |
} | |
.hexagon__inner.three { | |
-webkit-transform: rotateX(90deg) translateZ(150px); | |
} | |
.hexagon__inner.four { | |
-webkit-transform: translateZ(-150px); | |
} | |
.hexagon__inner.five { | |
-webkit-transform: rotateY(90deg) translateZ(-150px); | |
} | |
.hexagon__inner.six { | |
-webkit-transform: rotateX(90deg) translateZ(-150px); | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="hexagon"> | |
<div class="hexagon__inner one">1</div> | |
<div class="hexagon__inner two">2</div> | |
<div class="hexagon__inner three">3</div> | |
<div class="hexagon__inner four">4</div> | |
<div class="hexagon__inner five">5</div> | |
<div class="hexagon__inner six">6</div> | |
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// alert('Hello world!'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"view":"split-vertical","fontsize":"100","seethrough":"","prefixfree":"1","page":"all"} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment