【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);
  }
}
相关推荐
蜡台10 分钟前
Vue 打包优化
前端·javascript·vue.js·vite·vue-cli
木斯佳11 分钟前
前端八股文面经大全:快手前端一面 (2026-03-29)·面经深度解析
前端·宏任务·原型链·闭包
皙然25 分钟前
Redis配置文件(redis.conf)超详细详解
前端·redis·bootstrap
卷帘依旧1 小时前
JavaScript中this绑定问题详解
前端·javascript
dweizhao1 小时前
突发!Claude Code源码泄露了
前端
sunny_2 小时前
💥 Claude Code 源码泄露?我把这个最强 AI Coding Agent 的架构扒干净了
前端·agent·claude
西洼工作室2 小时前
React轮播图优化:通过延迟 + 动画的组合,彻底消除视觉上的闪烁感
前端·react.js·前端框架
yaaakaaang2 小时前
(八)前端,如此简单!---五组结构
前端·javascript
我是若尘2 小时前
我的需求代码被主干 revert 了,接下来我该怎么操作?
前端·后端·代码规范
魁首2 小时前
Claude Code 源码泄露的背后,到底与Codex,Gemini 有啥不一样?
前端·openai·claude