How to create a flip animation in CSS
The flip animation is one of several styling options that CSS provides.
The example below contains the HTML and CSS codes used to add the flip animation to images:
Explanation
- In the HTML code, the outermost container (
flip-container) is only used to set the animation area’s perspective; this specifies the space that the entire animation will use during the 3D flip effect. - The
flipperdiv is the container that actually flips between thefrontandbackdivs. - In the CSS file, on line 6, the
flippercontainer is set to “rotate” when the mouse hovers over theflip-containerdiv. - On line 14 in the CSS file, the property
backface-visibilityis set to “hidden” so that the back of the images do not appear during the flipping animation. - The settings for the animation, such as the flip speed and the 3D effect, are done on lines 19 – 24.
Free Resources
Copyright ©2026 Educative, Inc. All rights reserved