Vue 实现时间轴

<template>
  <div class="container">
    <div class="content">
      <div class="coin" v-for="(item,index1) in Math.ceil((list.length+1)/4)" :key="index1" v-show="isShow==index1">
        <div class="xs_one"></div>
        <div
          class="coinAll"
          v-for="(item, index) in list"
          :key="index"
          :class="{ one: index%4==0 }"
          v-show="index<(index1+1)*4 && index+1>(index1)*4"
        >
          <span
            :class="{
              two: (index + 1) % 2 == 0,
              text_active: index == isIndex,
            }"
          >
            {{ item }}
          </span>
          <div class="xs" :class="{ xs_active: index == isIndex }"></div>
          <img src="../assets/img/coin1.png" alt="" v-show="index == isIndex" />
          <img src="../assets/img/coin2.png" alt="" v-show="index != isIndex" />
        </div>
      </div>
      <div class="paging" :style="{width:Math.ceil((list.length+1)/4)*20+'px'}">
        <div class="pagings" v-for="(item,index1) in Math.ceil((list.length+1)/4)" :key="index1" @click="tabList(index1)" :class="{is_activ:isShow==index1}">{{index}}</div>
      </div>
    </div>
  </div>
</template>
 
 
<script>
export default {
  data() {
    return {
      list: ["实施方案", "任务书", "中期检查", "项目验收", "分页功能1","分页功能1","分页功能1","分页功能1","分页功能2"], //列表
      isIndex: 0, //高亮显示
      isShow: 1, //显示
    };
  },
  methods:{
    tabList(idx){
      this.isShow=idx
    }
  }
};
</script>
 
 
<style scoped>
.content {
  width: 400px;
  height: 120px;
  background: rgb(9, 27, 70);
  position: relative;
}
.paging{
  height: 20px;
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translate(-50%);
}
.paging div{
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: rgb(120, 120, 120);
  float: left;
  margin-left: 5px;
}
.coin {
  width: 100%;
  height: 80px;
  background: rgb(9, 27, 70);
  position: relative;
  overflow-x: hidden;
}
.xs_one {
  width: 100%;
  height: 5px;
  background: rgb(61, 183, 270);
  position: absolute;
  top: 50%;
  left: 0;
  transform: translate(0, -50%);
}
.coin .coinAll {
  width: 100px;
  height: 100%;
  float: left;
  position: relative;
}

.coin .one {
  margin-left: -50px;
}
.coin .coinAll img {
  position: absolute;
  top: 50%;
  right: 0;
  transform: translate(0, -50%);
}
.coin .coinAll .xs {
  width: 100%;
  height: 5px;
  background: rgb(61, 183, 270);
  position: absolute;
  top: 50%;
  left: 0;
  transform: translate(0, -50%);
}

.coin .coinAll span {
  width: 100%;
  color: #fff;
  font-size: 16px;
  position: absolute;
  top: 5px;
}
.coin .coinAll .two {
  width: 100%;
  color: #fff;
  font-size: 16px;
  position: absolute;
  top: 55px;
}

/* 文字高亮 */
.coin .coinAll .text_active {
  color: rgb(245, 189, 39);
}

/* 线条高亮 */
.coin .coinAll .xs_active {
  background: rgb(245, 189, 39);
}
.paging .is_activ{
  background: rgb(26, 82, 229);
}
</style>

效果如图

新增分页

 

  • 0
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

张建宇.

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值