I am a newbie with CSS and trying to implement a multistep React control based on some existing code (for the moment the steps are static, I will make things dynamic once I have figured out my problem):
import styles from "./ProgressSteps.module.css";
const ACProgressSteps = () =>{
return(
<div className={styles.container}>
<ul className={`${styles.progressbar} ${styles.nobullets}`}>
<li className={styles.selected}>Aircraft Type</li>
<li>Weight Index</li>
<li>Airport Times</li>
<li>Documents</li>
<li>Tada</li>
</ul>
</div>
)}
The active step is identified by {styles.selected} (and all previous steps with this style applied should also be marked as green). The corresponding styles are given below (I import them in my control):
.container{
width: 100%;
position: absolute;
z-index: 1;
}
.progressbar{
counter-reset: step;
}
ul.nobullets {
list-style-type: none; /* Remove bullets */
padding: 0; /* Remove padding */
margin: 0; /* Remove margins */
}
.progressbar li{
float: left;
width: 20%;
position: relative;
text-align: center;
}
.progressbar li:before{
counter-increment: step;
content:counter(step);
width: 30px;
height: 30px;
border: 2px solid #bebebe;
display: block;
margin: 0 auto 10px auto;
border-radius: 50%;
line-height: 27px;
background: white;
color: #bebebe;
text-align: center;
font-weight: bold;
}
.progressbar li:after{
content: '';
position: absolute;
width:100%;
height: 3px;
background: #979797;
top: 15px;
left: -50%;
z-index: -1;
}
.progressbar li:first-child:after{
content: none;
}
.progressbar li.selected + li:after{
background: #3aac5d;
}
.progressbar li.selected + li:before{
border-color: #3aac5d;
background: #3aac5d;
color: white
}
However, in the previous example, instead of having the first "step" selected, it's the second is as illustrated below (it seems I am having some kind of "off-by one issue"):
Any help on fixing this would be greatly appreciated!
Edit: as a courtesy to the original author, the example that I adapted can be found here: https://steemit.com/utopian-io/@alfarisi94/how-to-make-step-progress-bar-only-using-css
