Vue realizes click flip effect

Vue realizes click flip effect

Use vue to simply implement a click flip effect for your reference. The specific content is as follows

1.

2.

3.

//html code test demo naming copied randomly <div class="Demo">
        <div class="Before" :class="isTop ? 'contain-Before' : ''" @click="handleBefore"></div>
        <div class="After" :class="isTop ? 'contain-After' : ''" @click="handleAfter" style="font-size:20px;color:black">This is the back content</div>
    </div>

//Define isTop:false in data

//Method handleBefore() in methods{
  if(!this.isTop){
         this.isTop = true
     }
 },
 handleAfter(){
     if(this.isTop){
         this.isTop = false
     }
 }
//css
.Demo{
    width: 375px;
    height: 300px;
    margin-top: 50px;
    /* margin-left: 500px; */
    position: relative;
    perspective: 800px;
    box-sizing: border-box;
    
    
}
.Before{
    width: 100px;
    height: 200px;
    position: absolute;
    top:0;
    left: 0;
    background-repeat: no-repeat;
    background-position: center center;
    backface-visibility: hidden;
    transition: 1.5s;
    background-image:url('../assets/images/chunfen4.jpg');
    border:1px solid yellow;
 
}
.After{
    width: 100px;
    height: 200px;
    position: absolute;
    top:0;
    left: 0;
    color: #fff;
    background-color:#fff;
    text-indent: 2em;
    transform: rotateY(-180deg);
    backface-visibility: hidden;
    transition: 1.5s;
    border:1px solid yellow;
}
.Demo .contain-Before{
    transform: rotateY(180deg);
}
.Demo .contain-After{
    transform: rotateY(0deg);
}

You are done. If you want to slide and flip, remove the event yourself and add the :hover method to div.

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 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
  • Vue realizes the card flip effect

<<:  How to optimize MySQL deduplication operation to the extreme

>>:  Deploy Varnish cache proxy server based on Centos7

Recommend

Can Docker become the next "Linux"?

The Linux operating system has revolutionized the...

5 commonly used objects in JavaScript

Table of contents 1. JavaScript Objects 1).Array ...

MySQL 5.7.30 Installation and Upgrade Issues Detailed Tutorial

wedge Because the MySQL version installed on the ...

MySQL max_allowed_packet setting

max_allowed_packet is a parameter in MySQL that i...

Professional and non-professional web design

First of all, the formation of web page style main...

How to convert mysql bin-log log files to sql files

View mysqlbinlog version mysqlbinlog -V [--versio...

A thorough analysis of HTML special characters

A Thorough Analysis of HTML (14) Special Characte...

JavaScript to achieve all or reverse selection function

This article shares the specific code of JavaScri...

JS Asynchronous Stack Tracing: Why await is better than Promise

Overview The fundamental difference between async...

js to realize the mouse following game

This article shares the specific code of js to im...

Linux command line operation Baidu cloud upload and download files

Table of contents 0. Background 1. Installation 2...

Tips for turning pixels into comprehensive brand experiences

Editor: This article discusses the role that inte...

Solve the matching problem in CSS

Problem Description As we all know, when writing ...