You can use the CSS backface-visibility property in combination with the transform functions to create stunning flipping and revolving effect without using any JavaScript.
In the following example there are two images, one is front side and other is back side of the poker card. The back side of the card is placed over the front side using the CSS positioning method, so that at the beginning only one side of the card is visible.
When you place the cursor over the back side of the card it revolves and front side of the card will be displayed. The backface-visibility of both the front and back elements are hidden so that the back side of the flipped elements does not display during the transformation, which create the illusion of 3D rotation. Let's try it out to understand how 3D flipping exactly works:
You can also use two different <img> elements to display front and back side of the card instead of using them in the background, but you may feel some jerk at the beginning of the flip, because the image will take some time to load on the page. See example.
Note: Just replace the transform-function rotateY() with the rotateX() to create vertical flipping. You can also place the text or other elements inside the .front and .back<div> container to cutomize this example according to your need.
3D Flipping in Internet Explorer
The above example will not work in Internet Explorer as it should be, due to the lack of support for the CSS3 transform properties. However, flipping both the front and back elements at the same time, we can achieve the same effect as previous example. This example will work in IE10 and above.
Use the CSS
backface-visibilitypropertyYou can use the CSS
backface-visibilityproperty in combination with thetransformfunctions to create stunning flipping and revolving effect without using any JavaScript.In the following example there are two images, one is front side and other is back side of the poker card. The back side of the card is placed over the front side using the CSS positioning method, so that at the beginning only one side of the card is visible.
When you place the cursor over the back side of the card it revolves and front side of the card will be displayed. The
backface-visibilityof both the front and back elements arehiddenso that the back side of the flipped elements does not display during the transformation, which create the illusion of 3D rotation. Let's try it out to understand how 3D flipping exactly works:You can also use two different
<img>elements to display front and back side of the card instead of using them in thebackground, but you may feel some jerk at the beginning of the flip, because the image will take some time to load on the page. See example.Note: Just replace the transform-function
rotateY()with therotateX()to create vertical flipping. You can also place the text or other elements inside the.frontand.back<div>container to cutomize this example according to your need.3D Flipping in Internet Explorer
The above example will not work in Internet Explorer as it should be, due to the lack of support for the CSS3
need an explanation for this answer? contact us directly to get an explanation for this answertransformproperties. However, flipping both the front and back elements at the same time, we can achieve the same effect as previous example. This example will work in IE10 and above.