We have implemented a CSS-based progress bar.
The key CSS components are outlined below.
.container {
width: 600px;
margin: 20px auto;
}
.progressbar {
margin: 0;
padding: 0;
counter-reset: step;
}
.progressbar li {
list-style-type: none;
width: 25%;
float: left;
font-size: 12px;
position: relative;
text-align: center;
text-transform: uppercase;
color: #7d7d7d;
}
.progressbar li:before {
width: 30px;
height: 30px;
content: counter(step);
counter-increment: step;
line-height: 30px;
border: 2px solid #7d7d7d;
display: block;
text-align: center;
margin: 0 auto 10px auto;
border-radius: 50%;
background-color: white;
}
.progressbar li:after {
width: 100%;
height: 2px;
content: '';
position: absolute;
background-color: #7d7d7d;
top: 15px;
left: -50%;
z-index: -1;
}
...............
Here is the HTML structure:
<div class="container">
<ul class="progressbar">
<li class="active">login</li>
<li>choose interest</li>
........
A complete example can be viewed at https://jsfiddle.net/wbj7e79p/.
When there are seven steps, the layout becomes problematic. This is due to the fixed width of .progressbar li
set to 25%
. We attempted using calc(100% / steps)
or calc(100% / counter(steps))
, but neither solution worked. Any suggestions?
Keep in mind that we are developing a component that generates a dynamic progress bar on the fly, so the actual number of steps is unknown beforehand.