拐弯的时间线

<div ref="myElement"
              class="stepOut"
              :class="windowWidth <= 1024 ? 'stepOutSmall' : ''"
            >
              <ul>
                <li
                  class="stepItem"
                  v-for="(stepItem, index) in stepInfo"
                  :key="index"
                  :class="[
                    windowWidth <= 1024?  
                    Math.floor(index / 3) % 2 == 0? 'stepItemLeftStart': 'stepItemBrother'
                    : Math.floor(index / 6) % 2 == 0 ? 'stepItemLeftStart' : 'stepItemBrother'
                  ]"
                >
                  <!-- 模拟步骤条连接线,动态显示 一行最多展示6个,如果超过六个,连线则为圆弧状,如果是1024尺寸,则一行最多展示为3个
                  如果此步骤能不能整除6/3或者此步骤index+1除以6/3的余数可以整除2的话,显示之前(前提:当从左往右的时,判断当前步骤的索引是否大于步骤的长度来决定显示,当为从右往左时,则判断当前索引是否大于步骤的长度来决定显示) -->
                  <div
                    v-if="( windowWidth <= 1024
                    ? (index + 1) % 3 != 0 || ((index + 1) / 3) % 2 == 0
                    : (index + 1) % 6 != 0 || ((index + 1) / 6) % 2 == 0 ) && index!=stepInfo.length-1"
                    class="line"
                  ></div>
                  <!-- 圆弧线 如果可以整除6/3则为当前行的最后一个,显示为弧线 -->
                  <div
                    v-if="(windowWidth <= 1024? index != 0 && (index + 1) % 3 == 0: index != 0 && (index + 1) % 6 == 0) && index + 1 != stepInfo.length"
                    :class="['lineCircle',
                      windowWidth <= 1024
                      ? ((index + 1) / 3) % 2 == 0
                        ? 'lineCircleLeft'
                        : ''
                      : ((index + 1) / 6) % 2 == 0
                      ? 'lineCircleLeft'
                      : ''
                    ]"
                  ></div>
                  <div class="stepItemInner">
                    <div class="stepItemInner_content">
                      <img
                        class="step_bg"
                        :src="stepItem.status==1?require('../../../../../assets/images/odr/progress_bg1.png'):
                        stepItem.status==2?require('../../../../../assets/images/odr/progress_bg2.png'):
                        stepItem.status==3?require('../../../../../assets/images/odr/progress_bg3.png'):
                        require('../../../../../assets/images/odr/progress_bg4.png')"
                        alt=""
                      />
                      <!-- 时间  -->
                      <p class="stepTime">{{ stepItem.time }}</p>
                      <!-- 步骤名称  -->
                      <p class="stepStatus" :style="{color:stepItem.status==1?'#FF9900':stepItem.status==2?'#5398F7':stepItem.status==3?'#6C87EA':'#00C242'}">{{ stepItem.title }}</p>
                      <!-- 步骤描述  -->
                      <p class="statusDesc" v-html="stepItem.description"></p>
                    </div>
                  </div>
                </li>
              </ul>
            </div>
.stepOut {
    width:100%;
    display: flex;
    justify-content: center;
    margin-top:32px;
    ul{
      width:1000px;
    }
    &.stepOutSmall {
      // height:  137px;
      .stepItem {
        width: 160px;
        height: 137px;
        float: left;
        font-family: 'PingFangSC-Regular';
        font-size: 14px;
        text-align: center;
        position: relative;
        .lineCircle {
          // left: 55%;
          left:160px;
          top: 12px;
          position: absolute;
          display: block;
          border-left-color: white;
          border-left-width: 0px;
          width:77%;
          border-color: white white white white;
          border-left-style: hidden;
          border-left: none;
          border-top: 8px solid #f5f5f5;
          border-right: 8px solid #f5f5f5;
          border-bottom: 8px solid #f5f5f5;
          border-bottom: 8px solid #f5f5f5;
          border-left: 0px solid #c0c4cc;
          // height: 102%;
          border-radius: 0px 80px 80px 0px;
        }
        &:nth-child(n + 6) {
          float: inherit !important;
          right: inherit;
        }
        &:nth-child(n + 3) {
          float: right !important;
          right: 8%;
        }
        &.stepItemLeftStart {
          float: left !important;
          right: 0;
          + .stepItemBrother {
            .line {
              display: none;
            }
          }
        }
        .lineCircleLeft {
          left: -38%;
          width: 86%;
          border-top: 8px solid #f5f5f5;
          border-right: 0 solid #c0c4cc;
          border-bottom: 8px solid #f5f5f5;
          border-bottom: 8px solid #f5f5f5;
          border-left: 8px solid #f5f5f5;
          border-radius: 80px 0px 0px 80px;
          height:146px;
        }
        .line {
          position: absolute;
          top: 12px;
          left: 74.5%;
          border-bottom: 8px solid #f5f5f5;
          width: 160px;
          z-index: 111;
        }
      }
    }
    .stepItem {
      width: 160px;
      height: 137px;
      float: left;
      font-family: 'PingFangSC-Regular';
      font-size: 14px;
      text-align: center;
      position: relative;
      .stepItemInner {
        position: absolute;
        width: 120px;
        height: 91px;
        top: 8px;
        // left: 55%;
        z-index: 112;
        .stepItemInner_content {
          position: relative;
          width: 100%;
          height: 100%;
          .step_bg {
            width: 100%;
            height: 100%;
            position: absolute;
            left: 0;
            top: 0;
          }
          .stepTime {
            position: absolute;
            top: -21px;
            left: 50%;
            transform: translateX(-50%);
            font-size: 14px;
            color: #999999;
          }
          .stepStatus {
            position: absolute;
            top: 26px;
            left: 12px;
            font-size: 12px;
            color: #ff9900;
          }
          .statusDesc {
            position: absolute;
            top: 49px;
            left: 12px;
            font-size: 12px;
            color: #333333;
          }
        }
      }
      .lineCircle {
        left: 38%;
        top: 12px;
        position: absolute;
        display: block;
        border-left-color: white;
        border-left-width: 0px;
        width: 77%;
        border-color: white white white white;
        border-left-style: hidden;
        border-left: none;
        border-top: 8px solid #f5f5f5;
        border-right: 8px solid #f5f5f5;
        border-bottom: 8px solid #f5f5f5;
        border-bottom: 8px solid #f5f5f5;
        border-left: 0px solid #c0c4cc;
        height: 146px;
        border-radius: 0px 80px 80px 0px;
      }
      &:nth-child(n + 6) {
        float: right !important;
        right: 2%;
      }
      &.stepItemLeftStart {
        float: left !important;
        right: 0;
        + .stepItemBrother {
          .line {
            display: none;
          }
        }
      }
      .lineCircleLeft {
        left: -38%;
        width: 86%;
        border-top: 8px solid #f5f5f5;
        border-right: 0 solid #c0c4cc;
        border-bottom: 8px solid #f5f5f5;
        border-bottom: 8px solid #f5f5f5;
        border-left: 8px solid #f5f5f5;
        border-radius: 80px 0px 0px 80px;
        height:146px;
      }
      .line {
        position: absolute;
        top: 12px;
        // left: 74.5%;
        left:58px;
        border-bottom: 8px solid #f5f5f5;
        width:160px;
        z-index: 111;
      }
    }
  }

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Vue3 Timeline 时间线实现会拐弯时间轴相对于普通的时间线来说更加有趣和独特。在实现这种时间轴时,我们可以使用 Vue3 的组件化开发方式来创建一个可重复使用的时间线组件。 首先,我们需要创建一个 TimeNode(时间节点)组件,用来表示每个时间点。我们可以为每个节点设置一个时间和一个事件描述。时间节点可以通过计算属性或者接收传递的属性来设定其位置。 接下来,在时间线组件中,我们需要创建一个数组来存储时间节点。我们可以使用 v-for 指令来遍历这个数组,并将每个时间节点渲染到视图中。 然后,我们可以使用 CSS 来为时间节点添加样式,使其能够正确地显示出拐弯的效果。我们可以为时间节点设置不同的样式类,然后在 CSS 中定义这些样式类的样式规则,来实现时间轴的拐弯效果。 最后,我们可以根据时间节点的数量和位置,计算出时间轴的长度和位置,然后通过 CSS 来设置时间轴的样式,使其正确地显示出拐弯时间轴效果。 通过以上的步骤,我们就可以实现一个拐弯时间轴组件。这个组件可以根据需要接收传递的属性,可以根据时间节点的数量和位置来自动计算出时间轴的样式,使其能够正确地显示出拐弯的效果。 总之,Vue3 Timeline 时间线实现会拐弯时间轴,通过使用 Vue3 的组件化开发方式,结合计算属性、遍历数组、添加样式和计算位置等技巧,可以比较容易地实现出一个有趣和独特的时间轴组件。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值