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

无人久伴 提交于 2019-12-06 16:16:25

问题


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!


回答1:


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



来源:https://stackoverflow.com/questions/11764317/how-can-i-make-a-jquery-css-progression-bar-that-reflects-step-by-step-form-prog

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!