I'm in the process of building a progress bar with labels but i'm facing two problems.
- I need the label 6 to be lined up at the end of the progress bar as in the picture above.
respective code:
.lables{
display:flex;
justify-content: space-around;
color:white;
background-color:white;
}
I think that
justify-content: flex-end;
and
margin-left:calc(l00%/6 - width of each label);
might work but I don't know how to implement this or if there is a better solution.
- trying to make the progress bar rounded at both ends results in the entire bar becoming a circle. How do I achieve rounded border as in the picture above?
Entire html file:
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>skill bar</title>
</head>
<!-- style -->
<style>
.container{
max-width:790px;
margin: 0 auto;
}
.progress{
width: 100%;
background-color: dimgray;
}
.progress-bar{
width:0;
height: 10px;
background-color:limegreen;
}
.lables{
display:flex;
justify-content: space-around;
color:white;
background-color:white;
}
.lables > div{
background-color:dimgray;
text-align: center;
padding:10px;
margin:12px;
border-radius: 6px;
}
</style>
<!-- HTML -->
<body>
<div class="container">
<div class="progress">
<div class="lables">
<div> 1</div>
<div> 2</div>
<div> 3</div>
<div> 4</div>
<div> 5</div>
<div> 6</div>
</div>
<div class="progress-bar"></div>
</div>
<br>
<button onclick="move()">Click Me</button>
</div>
<!-- Javascript -->
<script>
function move(){
const element = document.querySelector('.progress-bar');
let width = 0;
let id = setInterval(frame, 20);
function frame(){
if(width>= 100){
clearInterval(id);
}else{
width++;
element.style.width = width + "%";
}
}
}
</script>
</body>
