鼠标移入,盒子展开收缩效果

image.png

        <div class="tabs-content">
            <div id="div1" @mouseenter="toggleDiv('div1')">
              <div class="tabs-content-item" v-show="signs == 'div1'">
                <div>能力简介</div>
                <div>
                  发了睡觉啊理发理发技术老骥伏枥手机辐射加夫里什肌肤垃圾法律纠纷拉上假发
                </div>
              </div>
              <div class="div-content" v-show="signs != 'div1'">
                <div>能力简介</div>
                <div></div>
              </div>
            </div>
            <div id="div2" @mouseenter="toggleDiv('div2')">
              <div class="tabs-content-item" v-show="signs == 'div2'">
                <div>建设现状</div>
                <div>
                  说啦放假啦时间发发介绍了放假啊路上风景垃圾分类上看金粉世家发顺丰
                </div>
              </div>
              <div class="div-content" v-show="signs != 'div2'">
                <div>建设现状</div>
                <div></div>
              </div>
            </div>
            <div id="div3" @mouseenter="toggleDiv('div3')">
              <div class="tabs-content-item" v-show="signs == 'div3'">
                <div>应用成效</div>
                <div>
                  了发酒疯啦就发酒疯啦时间放假啊垃圾放辣椒放了假啊放假啊了解放啦解放啦就发觉
                </div>
              </div>
              <div class="div-content" v-show="signs != 'div3'">
                <div>应用成效</div>
                <div></div>
              </div>
            </div>
            <div class="tabs-content-itemspecial">
              <div>查看详情</div>
              <div>
                <img
                  :src="require('@/assets/images/abilityoverview-dit.png')"
                  alt=""
                />
              </div>
            </div>
          </div>
//定义data
 signs: "div1", //div展开
 //展示效果
    toggleDiv(divId) {
      this.signs = divId;
      var div = document.getElementById(divId);
      var container = div.parentNode;
      // 遍历其他div元素,将它们的CSS样式恢复到正常状态
      for (var i = 0; i < container.children.length; i++) {
        var child = container.children[i];
        if (child.id !== divId) {
          child.classList.remove("expanded");
          child.classList.add("collapsed");
        }
      }
      // 切换当前div的展开/收缩状态
      div.classList.remove("collapsed");
      div.classList.add("expanded");
    },
  .tabs-content {
    margin-top: 30px;
    display: flex;
    height: 380px;
    justify-content: space-between;
    align-items: center;
  }
  .tabs-content-item {
    cursor: pointer;
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 40px 40px;
    border-radius: 10px;
    background: url("../assets/images/abilityoverview-big.png") no-repeat;
    background-size: 100% 100%;
    background-position: center;
    width: 100%;
  }
  .tabs-content-item > div:nth-child(1) {
    margin-bottom: 30px;
    font-family: YouSheBiaoTiHei;
    font-weight: 400;
    font-size: 32px;
    color: #6989b8;
    line-height: 30px;
  }
  .tabs-content-item > div:nth-child(2) {
    text-indent: 2em;
    font-weight: 400;
    font-size: 22px;
    color: #97a3a7;
    line-height: 36px;
  }
  .tabs-content-itemspecial {
    cursor: pointer;
    font-family: YouSheBiaoTiHei;
    font-weight: 400;
    font-size: 32px;
    color: #809dc8;
    line-height: 36px;
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    align-items: center;
    height: 100%;
    border-radius: 10px;
    background: url("../assets/images/abilityoverview-small.png") no-repeat;
    background-size: 100% 100%;
    background-position: center;
    width: 11%;
  }
  .tabs-content-itemspecial > div:nth-child(1) {
    writing-mode: vertical-rl;
    letter-spacing: 10px;
  }
  .tabs-content-itemspecial > div:nth-child(2) {
    width: 40px;
    height: 40px;
  }
.expanded {
  width: 65%;
}
.collapsed {
  width: 11%;
}
#div1 {
  transition: width 0.5s;
  transform-origin: left;
  height: 100%;
}
#div2 {
  transition: width 0.5s;
  transform-origin: left;
  height: 100%;
}
#div3 {
  transition: width 0.5s;
  transform-origin: left;
  height: 100%;
}
.div-content {
  cursor: pointer;
  font-family: YouSheBiaoTiHei;
  font-weight: 400;
  font-size: 32px;
  color: #809dc8;
  line-height: 36px;
  width: 100%;
  display: flex;
  align-items: center;
  flex-direction: column;
  justify-content: space-around;
  height: 100%;
  border-radius: 10px;
  background: url("../assets/images/abilityoverview-small.png") no-repeat;
  background-size: 100% 100%;
  background-position: center;
}
.div-content > div:nth-child(1) {
  writing-mode: vertical-rl;
  letter-spacing: 10px;
}
.div-content > div:nth-child(2) {
  width: 20px;
  height: 20px;
}
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容