Below is the demo where I am able to move the middle pointer using javascript. But I am unable to move the line which connects it from the start. Seems like I cannot give width property to :after
element of progress. What can I do here to achieve my goal. Please help
function myFunction(){
var middleDot = document.querySelector('.is-active');
var textinput = document.querySelector('#textinput');
middleDot.style.left = textinput.value+'%'
}
.progress-wrapper {
margin: 0 32px;
}
.progress {
padding: 40px 0;
position: relative;
width:100%
}
.progress::before,
.progress::after {
content: "";
background-color: #dfe3e4;
height: 5px;
position: absolute;
top: 50%;
transform: translateY(-50%);
left: 0;
}
.progress::before {
width: 100%;
}
.progress::after {
width: 50%;
background: #5D50DB;
}
.progress li {
position: relative;
list-style: none;
z-index: 1;
display: inline-block;
text-align:center;
}
.progress li:first-child {
left: 0;
}
.progress li.is-active {
left: 50%;
position: absolute;
}
.progress li:last-child {
float: right;
}
.progress > li:before {
content: "";
display: block;
margin: 0 auto;
background: #dfe3e4;
width: 20px;
height: 20px;
text-align: center;
line-height: 20px;
border-radius: 100%;
position: relative;
z-index: 1000;
}
.progress li:first-child:before {
background: #5D50DB;
}
.progress li.is-active:before {
background: #5D50DB;
}
.progress li span {
position: absolute;
bottom: -20px;
width: max-content;
left: 50%;
transform: translateX(-50%);
}
.is-active span{
top: -20px;;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<input type="text" id="textinput" value=50 onkeyup="myFunction()">
<div class="progress-wrapper">
<ol class="progress">
<li class="is-complete" data-step="1"><span>Place A</span></li>
<li class="is-active" data-step="2"><span>Place B</span></li>
<li data-step="3" class="progress__last"><span>Place C</span></li>
</ol>
</div>
</body>
</html>