CSS实现一个动态横向时间轴

CSS实现一个动态横向时间轴

先看效果


html

<template>
  <x-view class="stepFlex">
    <x-view
      v-for="(item, index) in testList"
      :key="index"
      style="position: relative; flex: 1; text-align: center;margin-top:-10px"
    >
      <x-view >{{ item.name }}</x-view>
      <x-view
        :class="item.ceshi == '1' ? 'greenCircle' :item.ceshi == '2' ? 'now' : 'greyCircle'"
      ></x-view>  
      <x-view
        v-if="index !== testList.length - 1"
        :class="testList[index + 1].ceshi != '3' ? 'greenline' : 'greyline'"
      ></x-view>
      <x-view style="margin-top:20px">{{ item.time }}</x-view>
    </x-view>
  </x-view>
</template>

css

.stepFlex {
  display: flex;
  .greenCircle {
    top: calc(50% - 4px);
    left: calc(50% - 4px);
    position: absolute;
    z-index: 2;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #08d0c3;
  }
  .now{
    top: calc(50% - 8px);
    left: calc(50% - 8px);
    position: absolute;
    z-index: 3;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #08d0c3;
    border: 4px solid #cef6f3;
  }
  .greyCircle {
    top: calc(50% - 4px);
    left: calc(50% - 4px);
    position: absolute;
    z-index: 2;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #ccc;
  }

  .greenline {
    width: 100%;
    top: calc(50% - 2px);
    left: calc(50% - 2px);
    height: 2px;
    background-color: #08d0c3;
    position: absolute;
  }

  .greyline {
    height: 0;
    border: 1px dashed #ccc;
    width: 100%;
    top: calc(50% - 2px);
    left: calc(50% - 2px);
    position: absolute;
  }
}

js

testList:[{
      name:'购买',
      time:'2019/01/25',
      ceshi:1
    },
    {
      name:'起息',
      time:'2019/01/25',
      ceshi:2
    },{
      name:'到期',
      time:'2019/01/25',
      ceshi:3
    }],
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值