"Connecting input range arc thumb to slider with curve v2"
Bootstrap 4.1.1 Snippet by muhittinbudak

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<link href="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
<script src="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<!------ Include the above in your HEAD tag ---------->
<div class="container">
<div class="range-wrap">
<!-- Ticks (lines) over slider -->
<div class="ticks" id="tickContainer">
</div>
<!-- Range value inside of range thumb -->
<div class="range-value" id="rangeValue"></div>
<!-- Range itself -->
<input id="range" type="range" min="1" max="100" value="5" step="1">
</div>
</div>
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
body {
font-family: Arial;
margin: 50px;
}
.range-wrap {
position: relative;
--svg:url("data:image/svg+xml;utf8, <svg xmlns='http://www.w3.org/2000/svg' viewBox='0 15 64 50' preserveAspectRatio='none' ><path d='M0 64 C16 64 16 32 32 32 C48 32 48 64 64 64 L64 48 C52 48 52 16 32 16 C12 16 12 48 0 48 L0 64 Z' fill='white'/></svg>") var(--p,0) 0;
}
/* Styling of ticks (lines) over the range */
.ticks {
--sw:120px; /* control the width of the curve */
position: absolute;
left: -30px;
right: -30px;
padding:0 10px;
height: 50px;
background: repeating-linear-gradient(to right, red 0 3px, transparent 1px 9px) content-box;
-webkit-mask:var(--svg) /var(--sw) 50px,
linear-gradient(to right, #fff calc(50% - var(--sw)/2 + 1px), transparent 0 calc(50% + var(--sw)/2 - 1px), #fff 0)
right var(--p) top 33px/calc(200% - var(--sw)) 16px;
-webkit-mask-repeat:no-repeat;
z-index:999;
}
/* Styling the range */
input[type=range] {
--sw:100px; /* control the width of the curve */
-webkit-appearance: none;
appearance: none;
margin: 20px 0 20px -20px;
padding:0 20px;
width:100%;
height: 90px;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// Position of span that shows range value and tick curve position
const tickContainer = document.querySelector('.range-wrap');
const range = document.getElementById('range');
const rangeV = document.getElementById('rangeValue');
const setValue = () => {
// Span position and inner value
const newValue = Number((range.value - range.min) * 100 / (range.max - range.min));
const newPosition = 30 - (newValue * 0.6);
rangeV.style.left = `calc(${newValue}% + (${newPosition}px))`;
rangeV.innerHTML = `${range.value}%`;
// Tick curve position
tickContainer.style.setProperty('--p', `calc(${newValue}%)`);
};
// Initialize setValue onload and oninput
document.addEventListener("DOMContentLoaded", setValue);
range.addEventListener('input', setValue);
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Related: See More


Questions / Comments: