Created
April 30, 2012 21:58
-
-
Save andymcfee/2563014 to your computer and use it in GitHub Desktop.
Flipping a cube
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
| /* | |
| * Flipping a cube | |
| */ | |
| /* Set-up */ | |
| body { | |
| color: rgb(6, 106, 117); | |
| text-transform: uppercase; | |
| font-family: sans-serif; | |
| font-size: 100%; | |
| background: #F4F6F8; | |
| padding: 3em 0 0 0; | |
| perspective: 5000px; /* <- NB */ | |
| } | |
| /* Container box to set animation 'relative' to */ | |
| .wrapper { | |
| width: 30%; | |
| text-align: center; | |
| margin: 0 auto; | |
| border: 1px solid rgb(147, 184, 189); | |
| } | |
| /* The two faces */ | |
| .flippety, | |
| .flop { | |
| background: rgb(247, 247, 247); | |
| border: 1px solid rgba(147, 184, 189, .8); | |
| box-shadow: | |
| 0 2px 5px rgba(105, 108, 109, .7), | |
| 0 0 8px 5px rgba(208, 223, 226, .4) inset; | |
| border-radius: 5px; | |
| box-sizing: border-box; | |
| transform-origin: center center; | |
| transition: transform 1s; | |
| height: 5em; | |
| } | |
| /* Positioning 'flop' to face down */ | |
| .wrapper .flop { | |
| transform: translateY(-50%) rotateX(-90deg); | |
| } | |
| /* The effect */ | |
| .wrapper:hover .flippety { | |
| transform: translateY(-50%) rotateX(90deg) ; | |
| } | |
| .wrapper:hover .flop { | |
| transform: translateY(-100%) rotateX(0deg); | |
| } | |
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
| <!-- content to be placed inside <body>…</body> --> | |
| <body> | |
| <div class="wrapper"> | |
| <div class="flippety"> | |
| <h1>Flippity</h1> | |
| </div> | |
| <div class="flop"> | |
| <h2>Flop</h2> | |
| </div> | |
| <p>Hover me</p> | |
| </div> | |
| </body> |
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","fontsize":"110","seethrough":"","prefixfree":"1","page":"all"} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment