当前位置: 首页 > news >正文

vue+element 实现蛇形时间轴 拐弯时间轴

在这里插入图片描述

公司业务需要做一个如图效果 分享给有需要的人 有更好的意见欢迎交流

核心代码如下

<div style="display: flex; position: relative">
 <div style="width: 89%; margin: auto; padding: 10px 0">
    <div v-for="(item, index) in experienceData" :key="index" style="display: flex">
      <div v-if="(index + 1) % 2 != 0" style="display: flex; width: 100%">
        <div
          v-for="(v, i) in displayProcessing(experienceData, index + 1)"
          :key="i"
          class="timeline"
          :style="{
            backgroundImage: `url(${require(`@/assets/p_${i}.png`)})`,
            backgroundRepeat: 'no-repeat',
            backgroundSize:
              displayProcessing(experienceData, index + 1).length < idx && (index + 1) % 2 != 0 ? '100% 25%' : 'contain',
            flex: displayProcessing(experienceData, index + 1).length < idx && (index + 1) % 2 != 0 ? '1' : 'none',
          }"
        >
          <div class="timeNodes">
            <div class="timeContent">
              <p class="nodeTimelis">
                <span>{{ v.content }}</span>
              </p>
            </div>
          </div>
        </div>
      </div>
      <div v-else style="display: flex; width: 100%; justify-content: end">
        <div
          v-for="(v, i) in displayProcessing(experienceData, index + 1)"
          :key="i"
          class="timeline2"
          :style="{
            backgroundImage:
              displayProcessing(experienceData, index + 1).length < idx && (index + 1) % 2 == 0
                ? `url(${require(`@/assets/p_0${idx - 2 - i}.png`)})`
                : `url(${require(`@/assets/p_0${idx - 1 - i}.png`)})`,
            backgroundRepeat: 'no-repeat',
            backgroundSize:
              displayProcessing(experienceData, index + 1).length < idx && (index + 1) % 2 == 0 ? '100% 25%' : 'contain',
            flex: displayProcessing(experienceData, index + 1).length < idx && (index + 1) % 2 == 0 ? '1' : 'none',
          }"
        >
          <div class="timeNodes">
            <div class="timeContent">
              <p class="nodeTimelis">
                <span>{{ v.content }}</span>
              </p>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>

数据

experienceData: [
  { content: '交换机外带管理' },
  { content: '交换机CLI界面调试' },
  { content: '交换机TELNET管理配置' },
  { content: '交换机生成树配置' },
  { content: '路由器TELNET管理配置' },
  { content: '路由器的外带管理' },
  { content: '交换机端口镜像配置' },
  { content: '链路聚合' },
  { content: '路由器带内管理' },
  { content: '路由器静态路由配置' },
  { content: '路由再发布' },
  { content: '静态路由(上、下)' },
  { content: 'IP编码与路由' },
  { content: 'TCP建立过程' },
  { content: 'OSI模型与TCP IP模型' },
],
idx: 4,//一行显示几个这里就写几

业务代码

displayProcessing(Arg, Num) {
  if (this.idx <= 0) {
    return []
  }
  let arr = Arg.slice(this.idx * (Num - 1), this.idx * Num)
  arr = Num % 2 == 0 ? arr.reverse() : arr
  return arr
},

css样式

.timeline {
  width: 200px;
  height: 60px;
}
.timeline2 {
  width: 200px;
  height: 60px;
}
.timeNodes {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  height: 100%;
  font-size: 14px;
  color: #3d3d3d;
}

.nodeTimelis {
  max-width: 150px;
  overflow: hidden;
  word-break: keep-all;
  white-space: nowrap;
  text-overflow: ellipsis;
}

完结

相关文章:

  • 使用查询,休眠-唤醒方式,POLL方式,异步通知方式,读取输入设备信息
  • 代码随想录算法训练营第22天 | 组合总和 分割回文串
  • PyTorch 中的混合精度训练方法,从 autocast 到 GradScalar
  • Windows编程----进程:命令行参数
  • 如何根据应用需求选择光谱相机
  • OpenCV计算摄影学(18)平滑图像中的纹理区域同时保留边缘信息函数textureFlattening()
  • 第五章 起航16 申请一个外包资源
  • 【Linux 22.4 ubuntu 安装cuda12.1 完整方案】
  • OFA:通过简单的序列到序列学习框架统一架构、任务和模态
  • 数学建模:MATLAB强化学习
  • 通过 Docker openssl 容器生成生成Nginx证书文件
  • 2025-03-07 :详细介绍一下 Databricks 的 Lakehouse
  • 【华为OD机试真题29.9¥】(E卷,100分) - 运维日志排序(Java Python JS C++ C )
  • OpenHarmony子系统开发编译构建指导
  • dart中实现子isolate的管理类,特适用于针对数据库的处理
  • 【js逆向】iwencai国内某金融网站实战
  • 心智模式—系统思考
  • 小白学Agent技术[1]
  • 初阶数据结构(C语言实现)——3.4带头双向循环链表详解(定义、增、删、查、改)
  • Android AudioFlinger(四)—— 揭开PlaybackThread面纱
  • 网站模式下做淘宝客/廊坊百度推广电话
  • 营销型网站建设的价格/网络营销工程师是做什么的
  • flash做的小动画视频网站/百度优化是什么
  • 做PPT的网站canva/网络营销做得好的企业有哪些
  • 好商网的网站可以做中英文切换吗/网络营销师有前途吗
  • 湖南电子科技网站建设/国外广告联盟平台