UPDATE:. This is an accepted answer. My first answer included the wrong animation, and since I used the rotate-3d property, it did not work in IE. For reference, my first answer is below accepted.
Since IE does not support save-3d, I modified the code to turn the eache side separately, but in just two divs this is not very important, and the code is pretty clean. Tested on Windows in Chrome 31, FF26, O18 and IE10. In IE9, it just flips the content without making a sharp transition, but it still works. For older support, I would probably just switch side visibility using the modernizr classes.
Demo
HTML
<div class="flip-card-content"> <div class="flip-card-side-a" style="background:red"> FRONT </div> <div class="flip-card-side-b" style="background:green"> BACK </div> </div> <button id="button">Flip</button>
CSS (using SCSS, vendor prefixes omitted for brevity)
.flip-card-content { position: relative; margin: 100px; width: 200px; height: 200px; transform-style: preserve-3d; perspective: 1000px; } .flip-card-side-a, .flip-card-side-b { width: 100%; position: absolute; height: 100%; backface-visibility: hidden; transform-origin: 50% 50%; transition: all .5s ease-in-out; } .flip-card-side-a { transform: rotateY(0deg) translateZ(100px); z-index: 1; // fixes buggy behavior in FF and Opera } .flip-card-side-b { transform: rotateY(90deg) translateZ(100px); } .flip .flip-card-side-a { transform: rotateY(-90deg) translateZ(100px); } .flip .flip-card-side-b { transform: rotateY(0deg) translateZ(100px); z-index: 1; }
By default, css rotates objects around the center, and you change them by setting the transform-origin property to some value (in this case, the top and middle). Since we changed the starting point for converting the rotating div to 180deg, we would put it above the red div, so we need to rotate 270deg to horizontally draw it on the plane in this way invisible. We get a cool knockback effect by setting the rotation back to 0deg per click or something else.
Demo
source share