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

The background color or image inside the div container grows as it grows

Copy code The code is as follows: height:auto !im...

Comparative Analysis of IN and Exists in MySQL Statements

Background Recently, when writing SQL statements,...

MySQL query sorting and paging related

Overview It is usually not what we want to presen...

Detailed explanation of Grid layout and Flex layout of display in CSS3

Gird layout has some similarities with Flex layou...

10 content-related principles to improve website performance

<br />English address: http://developer.yaho...

Summary of MySQL time statistics methods

When doing database statistics, you often need to...

Share the pitfalls of MySQL's current_timestamp and their solutions

Table of contents MySQL's current_timestamp p...

How to configure SSL for koa2 service

I. Introduction 1: SSL Certificate My domain name...

Preventing SQL injection in web projects

Table of contents 1. Introduction to SQL Injectio...

How to debug loader plugin in webpack project

Recently, when I was learning how to use webpack,...