Understanding the placement of notches on a slider is more intricate than using simple percentage values:
- first = 0%
- second = 33.3%
- third = 66.6%
- fourth = 100%
The slider-thumb
has specific dimensions, like 28px in your scenario.
Additionally, there are gaps before the first notch and after the last one...
The arrow icon also contributes to the width!
This makes calculating alignment quite complex...
I couldn't find a universal formula for all cases. However, by utilizing calc()
with a mix of "logical percentage" and pixel offset, you can achieve accurate positioning that remains responsive. It may require some trial and error to determine the correct offset.
Here are the specific lines I modified from your code snippet:
input[aria-valuenow='1'] + .range-slider-output::before {
left: 11px;
}
input[aria-valuenow='2'] + .range-slider-output::before {
left: calc(33.3% - 4px);
}
input[aria-valuenow='3'] + .range-slider-output::before {
left: calc(66.6% - 20px);
}
input[aria-valuenow='4'] + .range-slider-output::before {
left: calc(100% - 36px);
}
I've included bootstrap files as well (which were present in your fiddle).
Updated Fiddle
Working snippet