tabbar导航栏动画 自定义

复制代码
 <div class="box">
    <div class="container" id="my">
      <div class="item" v-for="(el,index) in item" :key="index" @click="isNum=index" :class="isNum==index?'active':''">
        <img :src="el.imge" alt="">
        <p class="text">{{el.name}}</p>
      </div>

      <div class="plus"></div>
    </div>
  </div>

 data() {
    return {
      isNum: 1,
      item: [
        { imge: require('../assets/20.png'), name: '首页' },
        { imge: require('../assets/30.png'), name: '首页' },
        { imge: require('../assets/40.png'), name: '首页' },
        { imge: require('../assets/50.png'), name: '首页' },
      ]
    }
  }

<style>
* {
  margin: 0;
  padding: 0;
}


.container {
  width: 400px;
  height: 70px;
  background-color: blue;
  display: flex;
  align-items: center;
  justify-content: space-around;
  text-align: center;
  color: #fff;
  position: relative;
  top: 50%;
  left: 50%;
  transform: translate(-50%, 100%);
}

.container .item img {
  width: 20px;
  height: 20px;
}

.container .item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.plus {
  position: absolute;
  left: 10px;
  top: -58%;
  background-color: rgb(231, 209, 7);
  width: 70px;
  height: 70px;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  border: 6px solid #fff;
  /* 过渡 */
  transition: 0.5s;

}

/* 圆弧 */
.plus::before {
  content: "";
  position: absolute;
  /* background: blue; */
  border-top-right-radius: 20px;
  width: 20px;
  height: 20px;
  top: 50%;
  left: -20px;
  box-shadow: 0 -10px 0 0 #fff;
}
.plus::after {
  content: "";
  position: absolute;
  border-top-left-radius: 20px;
  width: 20px;
  height: 20px;
  top: 50%;
  right: -20px;
  box-shadow: 0 -10px 0 0 #fff;
}

/* 选中样式 未选中样式 */
/* 未选中样式  文字 位移 不显示 */
.container .item img {
  position: absolute;
  font-size: 24px;
  /* 过渡 */
  transition: 0.5s;

}

.text {
  opacity: 0;
  font-weight: 600;
  transform: translateY(20px);
  /* 过渡 */
  transition: 0.5s; 
}

/* 选中样式 */
.item.active img {
  transform: translateY(-30px);
  z-index:99;
}

.item.active .text {
  opacity: 1;
  transform: translateY(15px);
}

.item:nth-child(1).active ~ .plus {
  transform: translateX(calc(100px * 0));
}

.item:nth-child(2).active ~ .plus {
  transform: translateX(calc(100px * 1));
}

.item:nth-child(3).active ~ .plus {
  transform: translateX(calc(100px * 2));
}

.item:nth-child(4).active ~ .plus {
  transform: translateX(calc(100px * 3));
}
相关推荐
韭菜炒大葱2 分钟前
🌟 var、let与const:JavaScript变量声明的前世今生
javascript·面试
庞囧2 分钟前
通俗易懂讲 React 原理-第二集:Fiber
前端
beckyye11 分钟前
给web增加简单的ai对话功能
前端·ai·通义千问·qwen
青衫码上行40 分钟前
【Java Web学习 | 第1篇】前端 - HTML
java·前端·学习
元直数字电路验证41 分钟前
HTML 标签及推荐嵌套结构
前端·javascript·html
charlie11451419142 分钟前
HTML 理论笔记
开发语言·前端·笔记·学习·html·1024程序员节
刚子编程1 小时前
ASP.NET Core Blazor 路由配置和导航
服务器·javascript·.netcore·blazor
海鸥两三1 小时前
Uni-App(Vue3 + TypeScript)项目结构详解 ------ 以 Lighting-UniApp 为例,提供源代码
vue.js·typescript·uni-app·1024程序员节
知识分享小能手1 小时前
uni-app 入门学习教程,从入门到精通,uni-app 企业项目实战:鲁嗑瓜子项目开发知识点(9)
前端·javascript·学习·微信小程序·小程序·uni-app·vue
阿金要当大魔王~~1 小时前
uniapp img 动态渲染 的几种用法
java·服务器·前端·1024程序员节