Vue realizes the card flip effect

Vue realizes the card flip effect

This article example shares the specific code of Vue to achieve the card flip effect for your reference. The specific content is as follows

1. Achieve results

Achieve a flip effect along the center Y axis by clicking.

2. Methods

It is divided into two parts, the front and the back. The div behind is set through the CSS layout to be flipped 180 degrees and hidden behind the div in the front. Click to execute the flip animation. When executing the flip animation, set the div behind to be displayed, and then hide the div in the front. Repeat in sequence.

3. Specific code

<template>
<div id="try">
 <!-- Perform front flip animation under box_rolling-->
<div class="rollbox" :class="{'box_rolling':isRolling}" @click="isRolling = !isRolling">
 <!-- front div -->
 <div class="rollbox_front">
  <div class="contentbox">
   <img src="@/assets/images/s1.png"/>
  </div>
 </div>
 <!-- next div -->
 <div class="rollbox_behind">
  <div class="contentbox">
   <img src="@/assets/images/s2.png"/>
  </div>
 </div>
</div>
</div>
</template>
<script>

export default{
 name:'try',
 data(){
  return {
   isRolling:false
  }
 }
}
</script>
<style lang='scss'>
#try{
 .rollbox{
  position: relative;
     perspective: 1000px;
  width:200px;
  height: 400px;
  margin:100px auto;

    &_front,
    &_behind{
   transform-style: preserve-3d; //Indicates that all child elements are presented in 3D space backface-visibility: hidden; //Whether the element is visible when the back is facing the screen transition-duration: .5s;
     transition-timing-function:'ease-in';
   background:#008080;
   .contentbox{
    width:200px;
    height: 400px;
    display: flex;
    justify-content: center;
    align-items: center;
    >img{
     width:100px;
    }
   }
    }
    &_behind{
      transform: rotateY(180deg);
      visibility:hidden; //The element is invisible, but occupies space position: absolute;
      top:0;
      bottom:0;
      right: 0;
      left: 0;
    }
 }
 .box_rolling{
    .rollbox_front{
      transform: rotateY(180deg);
      visibility:hidden;
    }
    .rollbox_behind{
      transform: rotateY(360deg);
      visibility:visible;
    }
  }
}
</style>

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • Vue realizes click flip effect
  • Vue implements card flip carousel display
  • Vue.js realizes large-screen digital scrolling and flipping effects
  • Vue image browsing component v-viewer usage analysis [supports rotation, scaling, flipping and other operations]
  • Vue iview multiple pictures large picture preview, zoom and flip

<<:  Deploy Varnish cache proxy server based on Centos7

>>:  How to create a database in navicat 8 for mysql

Recommend

HTML table tag tutorial (35): cross-column attribute COLSPAN

In a complex table structure, some cells span mul...

How to run postgreSQL with docker

1. Install Docker. Reference URL: Docker Getting ...

Analysis of Mysql data migration methods and tools

This article mainly introduces the analysis of My...

Detailed explanation of MySQL EXPLAIN output columns

1. Introduction The EXPLAIN statement provides in...

Summary of CSS sibling element floating analysis

float:left/right/none; 1. Same level floating (1)...

Detailed explanation of common usage methods of weixin-js-sdk in vue

Link: https://qydev.weixin.qq.com/wiki/index.php?...

Build Maven projects faster in Docker

Table of contents I. Overview 2. Conventional mul...

In-depth understanding of Vue transition and animation

1. When inserting, updating, or removing DOM elem...

Summary of three ways to create new elements

First: via text/HTML var txt1="<h1>Tex...

Detailed explanation of vite2.0+vue3 mobile project

1. Technical points involved vite version vue3 ts...

Select does not support double click dbclick event

XML/HTML CodeCopy content to clipboard < div c...

How to migrate sqlite to mysql script

Without further ado, I will post the code for you...

A detailed introduction to Linux memory management and addressing

Table of contents 1. Concept Memory management mo...