【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);
  }
}
相关推荐
计算机魔术师9 分钟前
别人IPO发股票,Anthropic一口气搞出五类
前端
ai_coder_ai28 分钟前
使用Web IDE边写自动化脚本
运维·前端·自动化
zhongben123_40 分钟前
从零开发一个打车APP:技术选型、系统架构与成本评估指南
大数据·运维·ios·系统架构·uni-app·web app
贾伟康1 小时前
【共创稿事节】一个 UserDataManager 管八类数据:Preferences 持久化的克制用法
java·服务器·前端·harmonyos·arkts·鸿蒙
卓豪终端管理1 小时前
【无标题】
java·服务器·前端
修炼的dance1 小时前
一条命令查清 WebM 有没有透明通道,默认解码会骗你
前端
小灰灰搞电子1 小时前
Rust+Slint 实现动态流光边框源码分享
开发语言·前端·rust·流光边框
niucloud-admin1 小时前
NIUCLOUD PHP SAAS上门家政使用文档:机构报表
前端·人工智能
枣把儿2 小时前
开源!全套公众号写作、封面、发布自动化工具包!
前端·命令行
陶醉的松鼠2 小时前
前端容易忽略的 debugger 调试技巧
前端