CSS3 Flip 3D Effect

Introduction

The CSS3 Flip 3D Effect displays content on the front and back sides of elements when the user interacts with them.
 
To implement the CSS3 Flip 3D Effect we need to understand some properties of CSS3. Let's understand the properties and then we will see an example of the Flip 3D Effect. 
    Margin: The margin properties define the space around elements.
     
    Float: The float property is used to specify whether or not a box should float.
     
    Position: Positions an element.
     
    Font Faimily: Defines a name.
     
    hover: How to style a element when we hover the mouse over it.
     
    -webkit: The prefix for Chrome and Safari.
     
    transform: The transform property applies a 2D or 3D transformation to an element. This property allows us to rotate, scale, move and/or skew elements. It is used with the prefix -webkit (for Chrome and Safari).

    perspective: The perspective property defines how many pixels a 3D element is placed from the view. It is only use for 3D transformed elements, it is used with the prefix -webkit (for Chrome and Safari).
     
    background: Sets properties such as background-color, background-position, background-size, background-repeat, background-origin, background-clip, background-attachment and background-image.
     
    color: Applys color on the text.

    border-radius: The border-radius property sets the four (top-left, top-right, bottom-right, bottom-left) border radius properties for defining the shape of the corners.
     
    backface-visibility: This property is useful when an element is rotated and you do not want to see its backside.
    • backface-visibility:hidden=>The backside is not visible.

    • backface-visibility:visible=>The backside is visible.

    transition: The transition property applys the four transition properties like transition-property, transition-duration, transition-timing-function and transition-delay.
 
Example: For the practicle implementation we will create an example. In this example I will create 4 Boxes using CSS3 Flip 3D Effect.
 
It is useful in many places, depending on requirements it makes creative effects for the elements.
 
We can also use this type of filp3D boxes in a MenuBar by lacing images or icons at the front side and text like Home, AboutUS and/or Contact as the back side of the boxes. In that manner we can create an animated menu.

Step 1
 
Open a text editor or write the following code and by run it to see the output and whatever images name we will use in the code. All these images should be present at the same location as our code file. 
  1. <!DOCTYPE html>  
  2. <html>  
  3. <head>  
  4. <style type="text/css">  
  5. .flipBox{ width:240px; height:200px; margin:10px; float:left; }  
  6. .flipBox > .front{  
  7.     position:absolute;  
  8.     -webkit-transform: perspective( 600px ) rotateY( 0deg );  
  9.     transform: perspective( 600px ) rotateY( 0deg );  
  10.     background:#F00; width:240px; height:200px; border-radius: 7px;  
  11.     color:#FFF;  
  12.     -webkit-backface-visibility: hidden;  
  13.     backface-visibility: hidden;  
  14.     transition: -webkit-transform .5s linear 0s;  
  15.     transition: transform .5s linear 0s;  
  16. }  
  17. .flipBox > .back{  
  18.     position:absolute;  
  19.     -webkit-transform: perspective( 600px ) rotateY( 180deg );  
  20.     transform: perspective( 600px ) rotateY( 180deg );  
  21.     background:#00F; width:240px; height:200px; border-radius: 7px;  
  22.     color:#FF0;  
  23.     -webkit-backface-visibility: hidden;  
  24.     backface-visibility: hidden;  
  25.     transition: -webkit-transform .5s linear 0s;  
  26.     transition: transform .5s linear 0s;  
  27. }  
  28. .flipBox:hover > .front{  
  29.     -webkit-transform: perspective( 600px ) rotateY( -180deg );  
  30.     transform: perspective( 600px ) rotateY( -180deg );  
  31. }  
  32. .flipBox:hover > .back{  
  33.     -webkit-transform: perspective( 600px ) rotateY( 0deg );  
  34.     transform: perspective( 600px ) rotateY( 0deg );  
  35. }  
  36. </style>  
  37. </head>  
  38. <body>  
  39. <div class="flipBox">  
  40.   <div class="back"></br>Price1<img src="bag.png"/></div>  
  41.   <div class="front"></br></br>Hello C# Corner Box1</div>  
  42. </div>  
  43. <div class="flipBox">  
  44.   <div class="back"></br>Price2<img src="tshirt.png"/></div>  
  45.   <div class="front"></br></br>Hello C# Corner Box2 </div>  
  46. </div>  
  47. <div class="flipBox">  
  48.   <div class="back"></br>Price3<img src="wrist_watch.png"/></div>  
  49.   <div class="front"></br></br>Hello C# Corner Box3</div>  
  50. </div>  
  51. <div class="flipBox">  
  52.   <div class="back"></br>Price4<img src="flash.png"/></div>  
  53.   <div class="front"></br></br>Hello C# Corner Box4</div>  
  54. </div>  
  55. </body>  
  56. </html>  
Step 2
 
I will save this file named "filpcss.html" and by run it in the Chrome browser to see output like this.
 
A) Click on the front side of box.
 
font side
 
B) Click on box2, flip the box2.
 
flip the box
 
C) Back side of box2.
 
side of box
 
D) Back side of box1.

back the site of box
 
E) Back side of box3.

back site of box image
 
F) Back side of box4.

back site of box pic
 
It is a simple example of the CSS3 Filp3D Effect. Happy coding. Thank you. 

Up Next
    Ebook Download
    View all
    Learn
    View all