Created
May 19, 2013 19:37
-
-
Save mikeplate/5608711 to your computer and use it in GitHub Desktop.
Box Flip
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
| <!DOCTYPE html> | |
| <title>Box Flip</title> | |
| <style> | |
| body { | |
| margin: 0px; | |
| font-family: Calibri, sans-serif; | |
| background-color: #eee; | |
| } | |
| * { | |
| -webkit-box-sizing: border-box; | |
| -moz-box-sizing: border-box; | |
| box-sizing: border-box; | |
| } | |
| .container { | |
| width: 500px; | |
| height: 500px; | |
| margin: 0px auto; | |
| -webkit-perspective: 800px; | |
| -moz-perspective: 800px; | |
| position: relative; | |
| } | |
| .box { | |
| width: 100%; | |
| height: 100%; | |
| position: absolute; | |
| -webkit-transition: -webkit-transform 1s; | |
| -webkit-transform-style: preserve-3d; | |
| -webkit-transform-origin: right center; | |
| -moz-transition: -moz-transform 1s; | |
| -moz-transform-style: preserve-3d; | |
| -moz-transform-origin: right center; | |
| } | |
| .box.flipped { | |
| -webkit-transform: translateX(-100%) rotateY(-180deg); | |
| -moz-transform: translateX(-100%) rotateY(-180deg); | |
| } | |
| .page { | |
| display: block; | |
| width: 100%; | |
| height: 100%; | |
| position: absolute; | |
| -webkit-backface-visibility: hidden; | |
| -moz-backface-visibility: hidden; | |
| } | |
| .page:nth-child(1) { | |
| background-color: red; | |
| } | |
| .page:nth-child(2) { | |
| background-color: blue; | |
| -webkit-transform: rotateY(180deg); | |
| -moz-transform: rotateY(180deg); | |
| } | |
| h1 { | |
| background-color: #be0d10; | |
| color: #fff; | |
| margin: 0px; | |
| padding: 10px; | |
| box-shadow: 0px 2px 2px #666; | |
| text-shadow: 1px 1px 1px #000; | |
| } | |
| p { | |
| padding: 20px; | |
| } | |
| </style> | |
| <div class="container"> | |
| <div class="box"> | |
| <div class="page"> | |
| <h1>Page One</h1> | |
| <p>This is the first page</p> | |
| </div> | |
| <div class="page"> | |
| <h1>Page Two</h1> | |
| <p>This is the second page</p> | |
| </div> | |
| </div> | |
| </div> | |
| <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script> | |
| <script> | |
| $(".container").bind("click", function(event) { | |
| $(".box").toggleClass("flipped"); | |
| }); | |
| </script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment