Progress bar made of solid line, with dots as steps

后端 未结 6 1773
[愿得一人]
[愿得一人] 2020-12-01 22:04

I\'m trying to create a vertical progress-bar, with 8 dots on a solid line (with the 8th on the end), where every dot stands for one step in the process. See attached screen

6条回答
  •  南笙
    南笙 (楼主)
    2020-12-01 22:23

    You can use box-shadow to achieve this effect.This can be achieved using a single element as it uses box-shadows but it will be hard to change the color using javascript

    Note:I used jquery to only show the effect of adding more to the progress bar click anywhere on the body to see the result

    $('body').click(function () {
        var x = parseInt($('.progressNow').css('top')) + 10;
        $('.progressNow').css({
            top: x
        })
        if (x > 90 - 800) {      $('.circle').css('background','#00b164')
        }
        if(x > 180 -800){
            $('.circle').css('box-shadow','0 90px 0 0 #00b164, 0 180px 0 0 #8fe4bf, 0 270px 0 0 #8fe4bf, 0 360px 0 0 #8fe4bf, 0 450px 0 0 #8fe4bf, 0 540px 0 0 #8fe4bf')
        }
        if(x > 270 -800){
            $('.circle').css('box-shadow','0 90px 0 0 #00b164, 0 180px 0 0 #00b164, 0 270px 0 0 #8fe4bf, 0 360px 0 0 #8fe4bf, 0 450px 0 0 #8fe4bf, 0 540px 0 0 #8fe4bf')
        }    
    })
    #progress {
        overflow:hidden;
        width:15px;
        padding-left:5px;
        height:800px;
        position: relative;
    }
    #progress .progressBar {
        height: 800px;
        width: 6px;
        background: #8fe4bf;
        position: absolute;
    }
    #progress .progressNow {
        height: 800px;
        top:-800px;
        width: 6px;
        background: #00b164;
        position: absolute;
    }
    .circle{
        content:"";
        width: 16px;
        height: 16px;
        border-radius: 50%;
        background: #8fe4bf;
        display: block;
        margin-left: -5px;
        position: absolute;
        top: 90px;
        box-shadow:0 90px 0 0 #8fe4bf, 0 180px 0 0 #8fe4bf, 0 270px 0 0 #8fe4bf, 0 360px 0 0 #8fe4bf, 0 450px 0 0 #8fe4bf, 0 540px 0 0 #8fe4bf;
    }
    
    

提交回复
热议问题