2021-09-10 工作记录-vue实现手风琴效果

一、vue实现手风琴效果

结果:

在这里插入图片描述
在这里插入图片描述

代码:

HTML:
在这里插入图片描述
对应代码:

<section class="star_intro pc">
      <div class="container">
        <div
          class="center"
          :class="{ activeCenter: activeIndex == index + 1 }"
          v-for="(studentImg, index) in PC_imgs"
          :key="index"
          @mouseenter="moveIn(index)"
          @mouseleave="moveOut()"
        >
          <div
            class="studentImg"
            :style="{ 'background-image': 'url(' + studentImg + ')' }"
          ></div>
          <div
            class="studentImg"
            :style="{ 'background-image': 'url(' + PC_bigImgs[index] + ')' }"
          ></div>
        </div>
      </div>
    </section>

CSS:
在这里插入图片描述
对应代码:

.star_intro {
  height: 360px;
  background-color: #fff;
}
.container {
  height: 100%;
  width: 81%;
  margin: auto;
  display: flex;
}
.center {
  width: calc((100% - 70px) / 8);
  height: 100%;
  margin-right: 10px;
  position: relative;
  transition: width 0.5s;
  box-sizing: border-box;
}
.center .studentImg {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 100%;
  height: 100%;
  object-fit: cover;
  background-repeat: no-repeat;
  background-position: center;
  background-size: cover;
}
.center .studentImg:last-child {
  background-position: left center;
  background-size: 100%;
  display: none;
}
.center:last-child {
  margin-right: 0;
}
.activeCenter {
  width: 42% !important;
}
.activeCenter .studentImg:last-child {
  display: block;
}

JS:
在这里插入图片描述
在这里插入图片描述
最后附上公司的优秀滴哥哥手写的手风琴:https://codepen.io/coder0309/pen/ZEyLJzx

  • 3
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小呀小萝卜儿

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值