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));
}
相关推荐
对空六课8 小时前
支持注意力分析的热力图工具有哪些?
前端·数据库·数据分析
Csvn9 小时前
Vue3 响应式与编译:依赖收集如何升级为节点级靶向更新
前端
星栈10 小时前
pnpm 12 升级实测
前端·javascript
Sirens.10 小时前
Java并发锁详解:六类锁策略与 synchronized 底层原理
java·前端·算法
Ai-_Man11 小时前
您您这可以把Microsofat Copilot的多个会话比如说。左侧的多个会话一次性导出吗?不是单条会话里面的多次会对话。AI导出鸭
javascript·人工智能·ai·小程序·电脑·copilot
特创数字科技12 小时前
一个纯本地运行的图片处理工具:压缩 / 裁剪 / 九宫格 / 圆角 / 滤镜 / 拼图 / 水印,终生使用
前端
IT_陈寒12 小时前
Vue的v-if和v-for混用居然是个天坑
前端·人工智能·后端
天衍四九-12 小时前
【无标题】
前端·spring boot·mysql·nginx·docker
广州华水科技12 小时前
2026年单北斗GNSS变形监测系统推荐榜单,解锁GNSS位移监测新高度
前端
xcyxiner12 小时前
DicomViewer24 修复编译bug(window test 失败)
前端·qt