Source Code:
(back to article)
Submit
Result:
Report an issue
<!DOCTYPE html> <html> <head> <title>Title of the document</title> <style> .floatL { float: left; } .floatR { float: right; } .clear { clear: both; line-height: 0; font-size: 0; display: block; } p { line-height: 10px; color: #333; margin: 5px 0; } #content { padding: 10px; background: #eeeeee; width: 400px; } .flip-container { perspective: 1000; width: 200px; } .flipper { transition: 0.8s; transform-style: preserve-3d; position: relative; height: 100px; } .front, .back { width: 200px; height: 100px; position: absolute; left: 0; top: 0; backface-visibility: hidden; color: #ffffff; font-weight: bold; font-size: 22px; line-height: 100px; text-align: center; } .back { transform: rotateY(180deg); background: #8ebf42; } .front { z-index: 2; background: #1c87c9; } .flip-container:hover .flipper, .flip-container.hover .flipper { transform: rotateY(-180deg); } .flip-container p { margin: 10px 0; text-align: center; } .bookflip-container .flipper { transform-origin: 0; } </style> </head> <body> <h2>3D Flip Box (Book Flip)</h2> <p>Hover over the box to see the effect:</p> <div id="content"> <div class="flip-container floatL" ontouchstart="this.classList.toggle('hover');"></div> <div class="flip-container bookflip-container floatR" ontouchstart="this.classList.toggle('hover');"> <div class="flipper"> <div class="front"> The front face </div> <div class="back"> The back face </div> <div class="clear"></div> </div> <p>Book Flip</p> </div> <div class="clear"></div> </div> </body> </html>