I would like to create a progress bar like this curve progress . But i don’t know how to make it. I created this one straight progress bar and here is my css code
JavaScript
x
35
35
1
.progbar{
2
top: 165px;
3
left: 100px;
4
width: 1450px;
5
height: 20px;
6
background: rgb(0, 157, 220);
7
position:absolute;
8
z-index: -1;
9
border-radius: 30%;
10
}
11
.progbar {
12
color: lightblue;
13
border-radius: 20px;
14
}
15
16
.progbar::-webkit-progress-value {
17
background: lightblue;
18
border-radius: 20px;
19
}
20
21
.progbar::-moz-progress-bar {
22
background: lightcolor;
23
border-radius: 20px;
24
}
25
26
.progbar::-webkit-progress-value {
27
background: rgb(153, 152, 152);
28
border-radius: 20px;
29
}
30
31
.progbar::-webkit-progress-bar {
32
background: rgb(0, 157, 220);
33
border-radius: 20px;
34
}
35
JavaScript
1
17
17
1
<div class="content">
2
<div class="mlogo">
3
<img id="mlogo" src="">
4
</div>
5
<div class="metroHat"> BAŞAKŞEHİR-METROKENT >> KİRAZLI</div>
6
<div><img class="metrologo" src="./images/metroistanbul-drm-ornek-07.png"></div>
7
<div class="lejant" id="lejant"></div>
8
<progress class="progbar" id="progress" value="0" max="100"></progress>
9
<div class="durakIsimleri" id="durakIsimleri"></div>
10
<div class="durakyerleri" id="durakyerleri"></div>
11
<div class="aktarmaNoktaları" id="aktarmaNoktaları"></div>
12
<div id="ok">
13
<!-- <img src="images/tren.png" /> -->
14
</div>
15
16
</div>
17
how can i curve to a progress bar ? is it possible or do i have to try an another tag?
Advertisement
Answer
My suggestion would be to use SVG and split the elements on the metro map into different <symbol>
elements. To construct the path/progress <use>
can be used and transformed into the right position.
The progress itself is made by a CSS selector for both the color of the lines and the dots. For the example you can use the range element to control the progress.
JavaScript
1
11
11
1
document.forms.form01.range.addEventListener('change', e => {
2
let numlines = parseInt(e.target.value);
3
let numdots = (numlines < 1) ? 0 : numlines+1;
4
document.querySelector('#styles').innerHTML = `
5
.lines use:nth-child(-n+${numlines}) {
6
stroke: DarkSlateBlue;
7
}
8
.dots use:nth-child(-n+${numdots}) {
9
stroke: DarkSlateBlue;
10
}`;
11
});
JavaScript
1
17
17
1
#line line {
2
stroke-width: 6px;
3
}
4
5
#dot circle {
6
stroke-width: 3px;
7
fill: white;
8
}
9
10
#down path, #up path {
11
stroke-width: 6px;
12
fill: none;
13
}
14
15
svg use {
16
stroke: SteelBlue;
17
}
JavaScript
1
36
36
1
<svg viewBox="0 0 250 50">
2
<defs>
3
<symbol id="line">
4
<line x1="0" y1="3" x2="40" y2="3" />
5
</symbol>
6
<symbol id="dot" transform="translate(-6 -3)">
7
<circle cx="6" cy="6" r="4" fill="white" />
8
</symbol>
9
<symbol id="down">
10
<path transform="translate(0 3)" d="M 0,0 C 25,0 15,20 40,20" />
11
</symbol>
12
<symbol id="up">
13
<path transform="translate(0 3)" d="M 0,20 C 25,20 15,0 40,0" />
14
</symbol>
15
</defs>
16
<style id="styles"></style>
17
<g class="lines">
18
<use href="#line" transform="translate(10 10)"/>
19
<use href="#line" transform="translate(50 10)"/>
20
<use href="#down" transform="translate(90 10)"/>
21
<use href="#up" transform="translate(130 10)"/>
22
<use href="#line" transform="translate(170 10)"/>
23
</g>
24
<g class="dots">
25
<use href="#dot" transform="translate(10 10)"/>
26
<use href="#dot" transform="translate(50 10)"/>
27
<use href="#dot" transform="translate(90 10)"/>
28
<use href="#dot" transform="translate(130 30)"/>
29
<use href="#dot" transform="translate(170 10)"/>
30
<use href="#dot" transform="translate(210 10)"/>
31
</g>
32
</svg>
33
34
<form name="form01">
35
<input type="range" name="range" min="0" max="5" value="0"/>
36
</form>