Search code examples
jqueryprogress

How can I make a jquery/css progression bar that reflects step by step form progression?


I see a lot of example progress bars that show the progression bar being filled up. However, I would just like to know how I could make a progress reflect step by step form progress. A good example of what I would want can be seen Here. Any helpful code or examples/demos from other pages would be good to have.

Thanks!


Solution

  • If you like the Buffalo one, just have a look at how they do it.

    First they define a div like this:

    <div id="progress">
        <div id="complete" class="s1">
            <div id="marker"></div>
        </div>
    </div>
    

    Then they use CSS to render the div based on the progress (which is controlled with class="s1" and so on).

    /**
     * PROGRESS
     */
    #progress,#complete {
        width: 520px;
        margin: 1px 0 19px;
        height: 32px;
        background:url(/img/backgrounds/progress.png);
        position:relative;
    }
    #complete {
        background-position: 0px 57px;
        margin-top: 0;
    }
    #complete #marker {
        position: absolute;
        top: 0;
        right: -26px;
        background:url(/img/backgrounds/markers.png);
        width: 26px;
        height: 32px;
    }
    #progress .s1 {
        width: 19px;
    }
    #progress .s2 {
        width:111px;
    }
    #progress .s3 {
        width:203px;
    }
    #progress .s4 {
        width:295px;
    }
    #progress .s5 {
        width:386px;
    }
    #progress .s6 {
        width:478px;
    }
    #progress .s2 #marker {
        background-position: -26px 0;
    }
    #progress .s3 #marker {
        background-position: -52px 0;
    }
    #progress .s4 #marker {
        background-position: -78px 0;
    }
    #progress .s5 #marker {
        background-position: -104px 0;
    }
    #progress .s6 #marker {
        background-position: -130px 0;
    }
    

    The CSS manipulates images to show the desired state

    enter image description here

    enter image description here