Vue implements zebra crossing progress bar

Look at the effect: 

Pictures used:

Save the two backgrounds of the progress bar first, the first is the background color black, and the second is the beige background used to show the progress

       

 Overall thought:

Use a small unit as the background image, and then set the length of the progress bar in the style, so that the background image will automatically fill and form a zebra crossing, thus realizing the progress bar.

html:

                <div class="progress">
                    <span>{
   
   {progress}}%</span>
                    <div class="p_bj">
                        <div class="p_layer" :style="{width:progress+'%'}">
                        </div>
                    </div>
                </div>

less:

      .progress {
            width: 100%;
            height: 60px;
            margin-top: 12px;
            background-image: url("../../../../assets/images/newImg/progress_bg.png");
            background-size: 100% 100%;
            position: relative;
            display: flex;
            align-items: center;
            span {
                position: absolute;
                left: 0;
                top: -8px;
                color: #b06c6c;
                font-size: 22px;
                font-weight: bold;
            }
            .p_bj {
                width: 96%;
                margin-left: 5px;
                height: 28px;
                background-position: 10px 10px;
                background-image: url("../../../../assets/images/newImg/p_2.png");
                .p_layer {
                    width: 38%;
                    height: 28px;
                    background-image: url("../../../../assets/images/newImg/p_1.png");
                    background-position: 10px 10px;
                }
            }
        }

data:

Changing the value of this progress can realize the change of progress

Guess you like

Origin blog.csdn.net/qq_41579104/article/details/129378346