vue实现点击翻转效果
用vue简单实现一个点击翻转的效果,供大家参考,具体内容如下
1、

2、

3、

//html代码 测试 demo命名随便复制来的<div class='Demo'><div : @click='handleBefore'></div><div : @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 方法
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持好吧啦网。
相关文章:
1. Docker 部署 Prometheus的安装详细教程2. notepad++运行python脚本的操作方法3. Docker究竟是什么 为什么这么流行 它的优点和缺陷有哪些?4. IntelliJ IDEA安装插件的方法步骤5. 使用Docker的NFS-Ganesha镜像搭建nfs服务器的详细过程6. python GUI库图形界面开发之PyQt5打印控件QPrinter详细使用方法与实例7. Laravel Many-To-Many多对多关系模式示例详解8. 推荐一个好看Table表格的css样式代码详解9. Notepad++如何安装Python插件?Notepad++插件怎么装?10. PHP 命名空间原理与用法详解

网公网安备