el-timeline实现左右两侧节点的效果

首先是效果图
在这里插入图片描述
主要实现方式就是这一段 left: index % 2 === 0 ? ‘20px’ : ‘-150px’,原理是通过index 判断如果是偶数行则让节点处于左侧,要记得添加position: 'absolute’样式才会生效

 <el-timeline style="margin-left: 50%">
        <el-timeline-item v-for="(item, index) in timelineData" :key="item.id" placement="top">
          <div style="display: flex; align-items: center;height: 50px;margin-bottom: 50px">
            <p :style="{
                marginBottom: '5px',
                opacity: '0.5',
                left: index % 2 === 0 ? '20px' : '-150px',
                position: 'absolute'
                  }">
              {{ item.auditorUserName !== null ? item.auditorUserName : item.initiatorUserName }}
              <br>
              {{ item.approvalTime }}
            </p>
            <el-card :style="{
                    width: '500px',
                    left: index % 2 === 0 ? '-520px' : null,
                    position: 'absolute'
                  }">
              <h2>{{ item.roleName }}</h2>
              <p style="margin-top: 5px">{{item.auditorUserName !== null ? item.approvalOpinion : '发起审批' }}</p>
            </el-card>
          </div>
        </el-timeline-item>
      </el-timeline>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值