Construct flip cards using transforms

Create a simple card flip animation on-hover with CSS 3D transforms.

Throughout this tutorial, you will grasp the technique of crafting a basic card flip animation employing CSS 3D transformations — all without the necessity of manual coding. Card rotations serve as an effective means to introduce visual dynamism by unveiling supplementary information. For instance, implementing a card flip animation enables you to highlight more specifics about a merchandise you are marketing. 

During this tutorial:

  1. Establish a Segment and Division block to encompass your card picture components
  2. Fashion card front and back picture components
  3. Configure the offspring perspective on the ancestor element
  4. Specify transformation properties on the card picture components
  5. Animate the Card wrapper to pivot upon hover 

Erect a Segment and Division block to house your card picture components

To kick things off, append a Segment on your page: 

  1. Unveil the Insert elements pane located in the left toolbar
  2. Drag a Segment onto your page

Position a Division block within the recently inserted Segment:

  1. Extract a Division block from the Insert elementspanel and embed it within the Segment previously established 
  2. Assign a class to the Division block (e.g., “Card wrapper”) 

Fabricate card front and back picture components

To insert and prepare your card picture components: 

  1. Drop 2 separate Picture components from the Insert elements pane and situate them within the Card wrapper Division block recently created 
  2. Select your initial picture and allot it a Class name of Card front. Redo this process for your subsequent picture, but designate it a Class name of Card back. 

To align images atop each other: 

Design, configure them to Display: Block. Ensure this adjustment is made for both pictures to have them overlapping.

Division block. Proceed to Spacing and arrange each image’s left and right margins to Auto. In case you desire a quicker method to center your images, click the Center element horizontally button for an automatic margin setup.

Design pane > Position, modify each image to Absolute and designate the Upper position. 

Having positioned your card images absolutely, both cards are piled. The Card back resides behind Card front.

  • Click on the Card front image
  • Navigate to Design 
  • Temporarily alter the Display to None
  • Establish the progeny perspective on the parent element

    Segment previously included on your page? Since it functions as the parent component of the Card wrapper Div block, we must set the section’s Offspring perspective. Enabling this perspective facilitates the display of our transformation in 3D. 

    1. Select the Segment
    2. Access the Design pane > Impacts > 2D & 3D transformations
    3. Engage the 3 disclosure dots to unveil Transformation configurations
    4. Beneath Offspring perspective, specify a Distance of 1234 pixels (you can always fine-tune this subsequently to match your desired 3D card flip appearance) 

    Specify transformation attributes on the card image components

  • Within the Design pane, proceed to Impacts and append a 2D & 3D transformation via the supplement icon 
  • Opt for Rotate and pivot the picture component by 180 degrees along the Y-axis 
    1. Revisit Impacts > 2D & 3D transformations
    2. Click the 3 disclosure dots to exhibit Transformation configurations 
    3. Designate Backface as Hidden
  • Select the Card front picture component
  • Adjust the Display to Block 
  • Single out the Card front component.
  • Head to Impacts > 2D & 3D transformations 
  • Click the 3 disclosure dots to unlock Transformation settings 
  • Determine Backface as Hidden
  • Animate the card wrapper to pivot upon hover

    1. Access the Selector field for the Card wrapper Division block 
    2. Opt for the Hover effect from the Selections drop-down list
    1. Activate the Hover effect and navigate to Modifications > 2D & 3D transformations 
    2. Hit the + sign and opt for the Rotate choice 
    3. Adjust the Card wrapper to rotate 180 degrees on the Y-axis

    In order to witness the flip animation you have created, revert back to the initial state of the Card wrapper Division block by selecting the Mode as Inactive

    Finally, incorporate a transition to the Card wrapper Division block. 

    1. Access the Appearance panel > Modifications > Transitions 
    2. Append a new transition using the additional button 
    3. From the Variety drop-down list, opt for Modification
    4. Include a duration of 1000 milliseconds 

    It’s time to rejoice — you have completed the task! Click on the preview button in the Designer to examine your card flip in motion. Hover over the card and exit to witness the card flip transition in action! Exhilarating!  

    Associated resources
    • ‍Read more about 2D and 3D Transformations
    • Discover more about 3D Perspective

    Ewan Mak
    Latest posts by Ewan Mak (see all)