Created
March 17, 2014 05:21
-
-
Save LeaVerou/9594360 to your computer and use it in GitHub Desktop.
3D cube
This file contains 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
/** | |
* 3D cube | |
*/ | |
body { | |
perspective: 600px; | |
perspective-origin: 300px -90px; | |
} | |
.cube, .cube:before, .cube:after, | |
.cube > div, .cube > div::before, .cube > div::after { | |
content: ""; | |
position: absolute; | |
width: 200px; height: 200px; | |
transform-origin: 0 0; | |
transform-style: preserve-3d; | |
} | |
.cube { | |
top: 100px; left: 100px; | |
background: hsla(0,100%,50%,.5); | |
transform-origin: center; | |
transform: rotateY(230deg) rotateX(0deg) rotateZ(0deg); | |
} | |
.cube > div { | |
transform-origin: 50% 100%; | |
transform: rotateX(90deg) rotateY(180deg); | |
background: hsla(180,100%,50%,.5); | |
} | |
.cube::before, | |
.cube > div::before { | |
background: hsla(60,100%,50%,.5); | |
transform: rotateX(-90deg); | |
} | |
.cube::after, | |
.cube > div::after { | |
background: hsla(120,100%,50%,.5); | |
transform: rotateY(-90deg) translateX(-100%); | |
} | |
.cube > div::before { | |
background: hsla(240,100%,50%,.5); | |
} | |
.cube > div::after { | |
background: hsla(300,100%,50%,.5); | |
} |
This file contains 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="cube"> | |
<div></div> | |
</div> |
This file contains 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 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":"css"} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment