【uniapp】自定义步骤条样式

代码实现

html 复制代码
<view class="steps-wrap">
  <view class="flex-box">
    <view class="number active-number">1</view>
    <view class="desc active-desc">步骤1</view>
    <view :class="['line', activeStep == 1 ? 'line1' : 'line3']"></view>
  </view>
  <view class="flex-box">
    <view :class="['number', activeStep == 1 ? '' : 'active-number']">2</view>
    <view :class="['desc', activeStep != 1 ? 'active-desc' : '']">步骤2</view>
    <view :class="['line', activeStep == 1 ? 'line2' : activeStep == 2 ? 'line1' : 'line3']"></view>
  </view>
  <view class="flex-box">
    <view :class="['number', activeStep == 3 ? 'active-number' : '']">3</view>
    <view :class="['desc', activeStep == 3 ? 'active-desc' : '']">步骤3</view>
  </view>
</view>
css 复制代码
.steps-wrap {
  padding: 36rpx 0 0;
  display: flex;
  align-items: center;
  .flex-box {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
  }
  .number {
    position: relative;
    z-index: 5;
    width: 40rpx;
    height: 40rpx;
    background: #9cccff;
    color: #fff;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 24rpx;
  }
  .active-number {
    background: var(--recruit-color);
  }
  .desc {
    font-size: 24rpx;
    color: #c8c8c8;
    line-height: 34rpx;
    margin-top: 20rpx;
    font-weight: 500;
    text-align: center;
  }
  .active-desc {
    color: #484848;
  }
  .line {
    position: absolute;
    top: 18rpx;
    left: 50%;
    z-index: 1;
    width: 100%;
    height: 4rpx;
  }
  .line1 {
    background: linear-gradient(90deg, #3a9aff 0%, #9cccff 21%, #9cccff);
  }
  .line2 {
    background: #9cccff;
  }
  .line3 {
    background: var(--recruit-color);
  }
}
相关推荐
沐言人生4 小时前
自媒体人的效率神器!监控、采集、下载、发布,这个免费开源工具全拿下!
前端·vue.js·后端
excel6 小时前
为什么 super 中能接收到 resolve 和 reject?
前端
Flynt8 小时前
AI 生成的界面,能放心点吗?我把 Google A2UI 的三层防线拆开测了一遍
前端·google·agent
前端混子9 小时前
我用 AI 做了个「禾月小历」,一套代码跑微信小程序和 H5
前端
IT_陈寒9 小时前
Java实战技巧总结:当你的finally块没有执行时会发生什么?
前端·人工智能·后端
小帅不太帅9 小时前
一年一次黑五,为了买软件真省钱,我做了个开源小站
前端·人工智能·github
JavaGuide11 小时前
刚刚,阿里版 Codex 上线了匿名模型 HungerG,无限 Token!
前端·后端
zhanlang021711 小时前
HTML 零基础入门到企业实战全套教程【第九章 9.3】移动端 HTML 基础适配入门
前端·html
用户693717500138412 小时前
AI 帮我写了大半年的代码,我却越来越不会写代码了
前端·后端·github
skywalk816312 小时前
把「假成功」赶出工具层:lightharness 两天升级复盘(4×5 模式矩阵 + 工具层 5 个缺陷)
开发语言·前端·人工智能·lightharness