CSS 斜条纹进度条

效果:

代码:

html:
<div class="active-line flex">
    <!-- lineWidth:灰色背景 -->
    <div class="bg-line">
        <div v-for="n in 30" class="gray"></div>
    </div>
    <div class="flex line-w">
        <!-- lineWidth:当前进度长度 -->
        <div class="line" :style="`width: ${lineWidth}px`"></div>
        <div class="round-dot" :style="lineWidth&&'width: 24upx'"></div>
    </div>
</div>
 css:
.active-line {
    width: 420upx;
    height: 12upx;
    // background: #EEEEEE;
    border-radius: 10upx;
    margin: 42upx 0 0 40upx;
    position: relative;
    .line-w {
        position: absolute;
        left: 0;
        top: 50%;
        -webkit-transform: translateY(-50%);
        transform: translateY(-50%);
        .line {
            border-radius: 10upx 0 0 10upx;
            height: 12upx;
            background: linear-gradient(30deg, #565F6F 0%, #212538 100%);
        }
        .round-dot {
            height: 24upx;
            border-radius: 50%;
            background: #212538;
        }
    }
}
.flex {
    display: flex;
    align-items: center;
}
.bg-line {
    padding: 0 6upx;
    display: flex;
    overflow: hidden;
    white-space: nowrap;
    border-radius: 6upx;

    .gray {
        display: inline-block;
        flex-shrink: 0;
        height: 12upx;
        width: 12upx;
        background-color: #eee;
        transform: skewX(-45deg);
        margin: 0 2upx;
    }
}
原理:斜条纹由多个带有倾斜角度的元素组成,直接用一个元素画不出来。
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值