vue怎么样做简单的点击翻转动画?
发布时间:2022-02-22 13:34:54 所属栏目:语言 来源:互联网
导读:这篇文章给大家分享的是有关用vue实现简单的点击翻转动画效果,点击翻转效果在网页设计中也比较常见,小编觉得挺实用的,因此分享给大家做个参考,接下来一起跟随小编看看吧。 //html代码 测试 demo命名随便复制来的 div class=Demo div class=Before :class
这篇文章给大家分享的是有关用vue实现简单的点击翻转动画效果,点击翻转效果在网页设计中也比较常见,小编觉得挺实用的,因此分享给大家做个参考,接下来一起跟随小编看看吧。 //html代码 测试 demo命名随便复制来的 <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"> 这个是背面内容</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); } 大功告成,如果想要滑过翻转的话自行去掉事件,给div添加 :hover 方法. (编辑:安阳站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |