css 巧用 ::after 实现 tab 切换动效

在这里插入图片描述

<template>
  <div class="container">
    <div class="tabBox">
      <div
        v-for="(item, index) in tabList"
        :key="index"
        class="tab"
        :class="{ active: index === activeIndex }"
        @click="activeIndex = index"
      >
        {
  { item.label }}
      </div>
    </div>
  </div>
</template>
<script>
export default {
     
  data() {
     
    return {
     
      activeIndex: 0,
      tabList: [
        {
     
          label: "精选好物",
        },
        {
     
          label: "炫酷动漫",
        },
        {
     
          label: "贺岁影院",
        },
      ],
    };
  },
};
</script>

<style lang="scss" scoped>
.tabBox {
     
  display: flex;
  justify-content: space-evenly;
  height: 100px;
  line-height: 90px;
  margin: 0 20px;
  font-size: 28px;
  border-radius: 10px;
  box-shadow: 0 4px 5px rgba(200, 200, 200, 0.3);
  color: #333;
  background-color: #fff;
  position: relative;
  z-index: 9;
  .tab {
     
    margin: 0 20px;
    position: relative;
    cursor: pointer;
  }
  .active {
     
    &::after {
     
      content: "";
      width: 40px;
      height: 4px;
      transform: translate(-50%);
      background-color: #27ba9b;
      position: absolute;
      left: 50%;
      bottom: 24px;
    }
  }
}
.container {
     
  margin: 30px;
}
</style>

相关推荐

  1. css实现文字下划线

    2023-12-12 19:12:04       40 阅读
  2. css鼠标悬浮

    2023-12-12 19:12:04       29 阅读

最近更新

  1. TCP协议是安全的吗?

    2023-12-12 19:12:04       16 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2023-12-12 19:12:04       16 阅读
  3. 【Python教程】压缩PDF文件大小

    2023-12-12 19:12:04       15 阅读
  4. 通过文章id递归查询所有评论(xml)

    2023-12-12 19:12:04       18 阅读

热门阅读

  1. 12、vue3(十二):用户管理页面搭建

    2023-12-12 19:12:04       37 阅读
  2. 定义一个存活态 HTTP 请求接口

    2023-12-12 19:12:04       37 阅读
  3. 12.11每日一题(备战蓝桥杯循环输出)

    2023-12-12 19:12:04       26 阅读
  4. 并发编程中的ConcurrentHashMap

    2023-12-12 19:12:04       37 阅读
  5. xtu oj 1327 字符矩阵

    2023-12-12 19:12:04       40 阅读
  6. Ubuntu(WSL)卸载与安装指定版本的 openssl

    2023-12-12 19:12:04       43 阅读
  7. 网络工程师【目录】

    2023-12-12 19:12:04       42 阅读
  8. w3school学习笔记3(NumPy)

    2023-12-12 19:12:04       36 阅读
  9. Qt-No relevant classes found. No output generated问题解决

    2023-12-12 19:12:04       38 阅读
  10. q2-qt-多线程

    2023-12-12 19:12:04       37 阅读
  11. 算法通关村第十八关 | 青铜 | 回溯

    2023-12-12 19:12:04       44 阅读
  12. Linux【2】:清理几天前的文件夹YYYYMMDD

    2023-12-12 19:12:04       35 阅读