css3d翻转

<div class="repast-cate-item-content">
  <div class="repast-cate-item-main">
    <img :src="item.main.imgSrc">
    <p>{{item.main.name}}</p>
  </div>
  <div class="repast-cate-item-back">
    <h4>{{item.back.name}}</h4>
    <p>{{item.back.intro}}</p>
  </div>
</div>
  .repast-cate .repast-cate-item-content{
    width: 440px;
    height: 300px;
    background: #fff;
    position: relative;
    perspective: 800px;
  }
  .repast-cate .repast-cate-item-content .repast-cate-item-main{
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    backface-visibility: hidden;
    transition: 1s;
    position: absolute;
    left: 0;
    top: 0;
  }
  /*.repast-cate .repast-cate-item-content .repast-cate-item-main img{*/
  /*  height: 96px;*/
  /*  margin-bottom: 30px;*/
  /*}*/
  /*.repast-cate .repast-cate-item-content .repast-cate-item-main p{*/
  /*  font-size: 30px;*/
  /*  color: #2C2C2C;*/
  /*}*/
  .repast-cate .repast-cate-item-content .repast-cate-item-back{
    width: 100%;
    height: 100%;
    background:rgba(43,194,163,1);
    padding: 37px 34px;
    box-sizing: border-box;
    color: #fff;
    backface-visibility: hidden;
    transform: rotateY(-180deg);
    transition: 1s;
    position: absolute;
    left: 0;
    top: 0;
  }
  /*.repast-cate .repast-cate-item-content .repast-cate-item-back h4{*/
  /*  font-size: 30px;*/
  /*  margin-bottom: 19px;*/
  /*}*/
  /*.repast-cate .repast-cate-item-content .repast-cate-item-back p{*/
  /*  font-size: 18px;*/
  /*}*/
  .repast-cate .repast-cate-item-content:hover .repast-cate-item-main{
    transform: rotateY(180deg);
  }
  .repast-cate .repast-cate-item-content:hover .repast-cate-item-back{
    transform: rotateY(0deg);
  }

backface-visibility: hidden; 这个属性的作用就是翻转过去的内容被隐藏了,所以我们只能看到一个面的内容。就达到了一个卡片2个面切换显示。
transform: rotateY(-180deg); 这个是css3的翻转功能,但是要想实现3d效果还要加上景深perspective: 800px;

效果图:
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值