vue--鼠标经过卡片具有动态阴影效果

样式效果:
在这里插入图片描述
代码说明:

设置一整个为ul标签,每一个卡片作为一个li标签,最重要的是进行样式设置。
serviceCodeList 是每个卡片中的信息数据,由后端返回,格式先不贴了,点击事件也不必关注

代码:

<ul class="home-box">
        <li @click="goToService(service)" class="item home-item" v-for="service in serviceCodeList" :key="service.serviceCode">
          <div class="img-box">
            <img :src="service.imgSrc" alt="" />
          </div>
          <div class="name">{{ service.serviceName }}</div>
          <div class="item-hover">点击进入</div>
        </li>
      </ul>
<style lang="scss">
ul{
      display: flex;
      margin: 0 auto;
      max-width: 1200px;
      justify-content: center;
      align-items: flex-start;
      flex-wrap: wrap;
    }
.item{
      width: 200px;
      height: 219px;
      padding: 20px;
      margin: 0 15px 15px;
      background: $light-color;
      box-shadow: 0 2px 10px 0 rgba(23, 70, 161, .11);
      overflow: hidden;
      border:1px solid rgba(0, 0, 0, 0.12);
      border-radius: 4px;
      transition: box-shadow .25s ease,transform .25s ease,-webkit-transform .25s ease;
      &:hover{
        transform: translate3d(0,-5px,0);
        box-shadow: 0 1.5rem 2.5rem rgba(22,28,45,.1),0 .3rem 0.5rem -.50rem rgba(22,28,45,.05) !important;
      }
    }
.item-hover{
    position: absolute;
    height: 0;
    bottom: 0;
    left: 0;
    right: 0px;
    overflow: hidden;
    background: $banner-bg;
    // color: $light-color;
    color: #7ff3f2;
    z-index: 1;
    transition: all .25s;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  
&:hover .item-hover{
      height: 44px;
    }
</style>

不理解transition,可看transition transform

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值