Created
February 12, 2014 15:05
-
-
Save vpell/8957123 to your computer and use it in GitHub Desktop.
Based on http://davidwalsh.name/css-flip (IE version). The perspective effect ("perspective: 1000px;") don't work in Firefox 27.
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
| /* | |
| *************************** | |
| http://davidwalsh.name/css-flip [IE version] | |
| *************************** | |
| 1. work in Safari 7.0.1 | |
| 2. work in Chrome 32.0.1700.107 | |
| 3. work partially in Firefox 27 | |
| */ | |
| .container { | |
| width: 70%; | |
| margin: auto; | |
| margin-top: 20px; | |
| background: red; | |
| } | |
| .flip-container { | |
| margin: auto; | |
| /* keeps perspective in the entire container */ | |
| -webkit-perspective: 1000px; | |
| -moz-perspective: 1000px; | |
| perspective: 1000px; | |
| } | |
| /* flip the pane when hovered */ | |
| .flip-container:hover .back { | |
| transform: rotateY(0deg); | |
| } | |
| /* flip the pane when hovered */ | |
| .flip-container:hover .front { | |
| -webkit-transform: rotateY(180deg); | |
| -moz-transform: rotateY(180deg); | |
| -o-transform: rotateY(180deg); | |
| -ms-transform: rotateY(180deg); | |
| transform: rotateY(180deg); | |
| } | |
| .flip-container, .front, .back { | |
| width: 240px; | |
| height: 240px; | |
| } | |
| .flipper { | |
| position: relative; | |
| } | |
| .front, .back { | |
| position: absolute; | |
| top: 0; | |
| left: 0; | |
| /* hide back of pane during swap */ | |
| -webkit-backface-visibility: hidden; | |
| -moz-backface-visibility: hidden; | |
| backface-visibility: hidden; | |
| /* flip speed goes here (for IE compatibility) | |
| Else put it in .flipper */ | |
| -webkit-transition: 0.4s; | |
| -moz-transition: 0.4s; | |
| -o-transition: 0.4s; | |
| -ms-transition: 0.4s; | |
| transition: 0.4s; | |
| -webkit-transform-style: preserve-3d; | |
| -moz-transform-style: preserve-3d; | |
| -ms-transform-style: preserve-3d; | |
| transform-style: preserve-3d; | |
| } | |
| .front { | |
| z-index: 2; | |
| background: silver; | |
| text-align: center; | |
| line-height: 240px; | |
| font-size: 80px; | |
| color: #005e5c; | |
| } | |
| /* original position of the image (reverse horizontal symetry) */ | |
| .back { | |
| -webkit-transform: rotateY(-180deg); | |
| -moz-transform: rotateY(-180deg); | |
| -o-transform: rotateY(-180deg); | |
| -ms-transform: rotateY(-180deg); | |
| transform: rotateY(-180deg); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment