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 resultsAchieve a flip effect along the center Y axis by clicking. 2. MethodsIt 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:
|
<<: Deploy Varnish cache proxy server based on Centos7
>>: How to create a database in navicat 8 for mysql
Copy code The code is as follows: height:auto !im...
Background Recently, when writing SQL statements,...
Overview It is usually not what we want to presen...
What is Docker-Compose The Compose project origin...
Gird layout has some similarities with Flex layou...
<br />English address: http://developer.yaho...
When doing database statistics, you often need to...
This article mainly introduces the implementation...
Table of contents MySQL's current_timestamp p...
What is a descending index? You may be familiar w...
First, let me explain that what we want to do is ...
I. Introduction 1: SSL Certificate My domain name...
There was a shaking barrage on TikTok a while ago...
Table of contents 1. Introduction to SQL Injectio...
Recently, when I was learning how to use webpack,...