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));
}
相关推荐
程序员黑豆5 小时前
Java包装类:基本类型与对象的桥梁
java·前端·ai编程
bugcome_com7 小时前
JWT 知识小课堂:从入门到精通,一文吃透 JSON Web Token
前端·json
To_OC8 小时前
写了三天 Next.js,我的 React 世界观被拆了又装回去
前端·全栈·next.js
独泪了无痕8 小时前
viewer.js 安装与配置指南:实现图片预览功能
前端·vue.js
起床学FPGA9 小时前
AI回答问题之后,会自动跳到最下面的问题
开发语言·javascript·ecmascript
Fluxart.ai10 小时前
电商商品图审核怎么自动化?规则引擎、人工复核与发布门禁
java·前端·自动化
why技术10 小时前
AI 写的文章,可能都带着手敲一遍都去不掉的“隐形水印”。
前端·人工智能·后端
愚公搬代码10 小时前
【愚公系列】《Android应用案例开发大全》016-LBS类应用掌上杭州(辅助工具类的开发)
android·前端
CodeSheep11 小时前
又一个华为天才少年,离职了!
前端·后端·程序员
kyriewen11 小时前
面试官说"打开你的AI工具"——我才发现,他考的根本不是写代码
前端·人工智能·面试