【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);
  }
}
相关推荐
摸鱼仙人~1 小时前
styled-components:现代React样式解决方案
前端·react.js·前端框架
sasaraku.1 小时前
serviceWorker缓存资源
前端
RadiumAg2 小时前
记一道有趣的面试题
前端·javascript
yangzhi_emo2 小时前
ES6笔记2
开发语言·前端·javascript
yanlele3 小时前
我用爬虫抓取了 25 年 5 月掘金热门面试文章
前端·javascript·面试
中微子4 小时前
React状态管理最佳实践
前端
米粒宝的爸爸4 小时前
uniapp在app端,在导航栏设置自定义按钮
uni-app
烛阴4 小时前
void 0 的奥秘:解锁 JavaScript 中 undefined 的正确打开方式
前端·javascript
中微子4 小时前
JavaScript 事件与 React 合成事件完全指南:从入门到精通
前端
Hexene...4 小时前
【前端Vue】如何实现echarts图表根据父元素宽度自适应大小
前端·vue.js·echarts