Vue實(shí)現(xiàn)牌面翻轉(zhuǎn)效果
本文實(shí)例為大家分享了Vue實(shí)現(xiàn)牌面翻轉(zhuǎn)效果的具體代碼,供大家參考,具體內(nèi)容如下
1.實(shí)現(xiàn)效果
實(shí)現(xiàn)一個(gè)點(diǎn)擊沿中心Y軸翻轉(zhuǎn)的翻轉(zhuǎn)效果。

2.方法
分前(front)、后(behind)兩部分,behind的div通過css布局設(shè)定為將其翻轉(zhuǎn)180度在front的div后面隱藏不顯示,點(diǎn)擊執(zhí)行翻轉(zhuǎn)動(dòng)畫,在執(zhí)行翻轉(zhuǎn)動(dòng)畫的時(shí)候設(shè)置behind的div顯示,之后將front的div隱藏.依次反復(fù)。
3.具體代碼
<template>
<div id="try">
<!-- box_rolling下執(zhí)行正面翻轉(zhuǎn)動(dòng)畫 -->
<div class="rollbox" :class="{'box_rolling':isRolling}" @click="isRolling = !isRolling">
<!-- 前面div -->
<div class="rollbox_front">
<div class="contentbox">
<img src="@/assets/images/s1.png"/>
</div>
</div>
<!-- 后面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; //表示所有子元素在3D空間中呈現(xiàn)
backface-visibility: hidden; //元素背面向屏幕時(shí)是否可見
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; //元素不可見,但占據(jù)空間
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>
以上就是本文的全部內(nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
vue.js2.0 實(shí)現(xiàn)better-scroll的滾動(dòng)效果實(shí)例詳解
better-scroll 是一個(gè)移動(dòng)端滾動(dòng)的解決方案,它是基于 iscroll 的重寫。better-scroll 也很強(qiáng)大,不僅可以做普通的滾動(dòng)列表,還可以做輪播圖、picker 等等,下面通過本文給大家介紹vue.js2.0 實(shí)現(xiàn)better-scroll的滾動(dòng)效果,感興趣的朋友一起看看吧2018-08-08
vue導(dǎo)出少量pdf文件實(shí)現(xiàn)示例詳解
這篇文章主要為大家介紹了vue導(dǎo)出少量pdf文件實(shí)現(xiàn)示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-06-06
Vue項(xiàng)目自動(dòng)轉(zhuǎn)換 px 為 rem的實(shí)現(xiàn)方法
這篇文章主要介紹了Vue項(xiàng)目自動(dòng)轉(zhuǎn)換 px 為 rem的實(shí)現(xiàn)方法,本文是通過一系列的配置后,轉(zhuǎn)換成熱門,具體內(nèi)容詳情大家跟隨小編一起通過本文學(xué)習(xí)吧2018-10-10
在vant中使用時(shí)間選擇器和popup彈出層的操作
這篇文章主要介紹了在vant中使用時(shí)間選擇器和popup彈出層的操作,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧2020-11-11
vue復(fù)合組件實(shí)現(xiàn)注冊(cè)表單功能
這篇文章主要為大家詳細(xì)介紹了vue復(fù)合組件實(shí)現(xiàn)注冊(cè)表單功能,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-11-11

