【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);
  }
}
相关推荐
浏览器API调用工程师_Taylor11 分钟前
日报自动化实战:告别手动复制粘贴
前端·javascript·node.js
晴殇i17 分钟前
JavaScript还能这样写?!ES2025新语法让代码优雅到极致
前端·javascript·程序员
浏览器API调用工程师_Taylor26 分钟前
我是如何将手动的日报自动化的☺️☺️☺️
前端·javascript·爬虫
2501_915921431 小时前
iOS 抓包工具有哪些,开发者的选型与实战指南
android·ios·小程序·https·uni-app·iphone·webview
前端Hardy1 小时前
HTML&CSS&JS:抖音爆火的满屏“关心弹幕”酷炫卡片,已经帮你打包好了,快来体验吧!
前端·javascript·css
江城开朗的豌豆1 小时前
我的Vue项目胖成球了!用Webpack给它狠狠瘦个身
前端·javascript
WebInfra1 小时前
Rspack 1.6 发布:让打包产物更小、更纯净
前端·javascript·前端框架
2501_915918411 小时前
iOS 26 应用管理实战 多工具协同构建开发与调试的高效体系
macos·ios·小程序·uni-app·objective-c·cocoa·iphone
Mintopia1 小时前
⚙️ Next.js 接口限流与审计全攻略 —— 用 @upstash/ratelimit 打造优雅“闸门”
前端·javascript·全栈
Mintopia2 小时前
🌐 实时翻译 + AIGC:Web跨语言内容生成的技术闭环
前端·javascript·aigc