vue實現(xiàn)點擊翻轉(zhuǎn)效果
用vue簡單實現(xiàn)一個點擊翻轉(zhuǎn)的效果,供大家參考,具體內(nèi)容如下
1、
2、
3、
//html代碼 測試 demo命名隨便復(fù)制來的<div class='Demo'><div : @click='handleBefore'></div><div : @click='handleAfter' style='font-size:20px;color:black'>這個是背面內(nèi)容</div> </div>//在data中定義isTop:false//methods中的方法handleBefore(){ 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);}
大功告成,如果想要滑過翻轉(zhuǎn)的話自行去掉事件,給div添加 :hover 方法
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持好吧啦網(wǎng)。
相關(guān)文章:
1. vue實現(xiàn)web在線聊天功能2. IntelliJ IDEA設(shè)置自動提示功能快捷鍵的方法3. Java Bean與Map之間相互轉(zhuǎn)化的實現(xiàn)方法4. SpringBoot+TestNG單元測試的實現(xiàn)5. Springboot 全局日期格式化處理的實現(xiàn)6. Java使用Tesseract-Ocr識別數(shù)字7. Python使用urlretrieve實現(xiàn)直接遠(yuǎn)程下載圖片的示例代碼8. Django使用HTTP協(xié)議向服務(wù)器傳參方式小結(jié)9. JAMon(Java Application Monitor)備忘記10. 完美解決vue 中多個echarts圖表自適應(yīng)的問題
