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));
}
相关推荐
沙振宇33 分钟前
【Web】使用Vue3开发鸿蒙的HelloWorld!
前端·华为·harmonyos
运维@小兵1 小时前
vue开发用户注册功能
前端·javascript·vue.js
蓝婷儿1 小时前
前端面试每日三题 - Day 30
前端·面试·职场和发展
oMMh2 小时前
使用C# ASP.NET创建一个可以由服务端推送信息至客户端的WEB应用(2)
前端·c#·asp.net
一口一个橘子2 小时前
[ctfshow web入门] web69
前端·web安全·网络安全
读心悦3 小时前
CSS:盒子阴影与渐变完全解析:从基础语法到创意应用
前端·css
m0_616188493 小时前
使用vue3-seamless-scroll实现列表自动滚动播放
开发语言·javascript·ecmascript
香蕉可乐荷包蛋4 小时前
vue数据可视化开发echarts等组件、插件的使用及建议-浅看一下就行
vue.js·信息可视化·echarts
老马啸西风4 小时前
sensitive-word-admin v2.0.0 全新 ui 版本发布!vue+前后端分离
vue.js·ui·ai·nlp·github·word
湛海不过深蓝4 小时前
【ts】defineProps数组的类型声明
前端·javascript·vue.js