I'm building a range/slider to compare a users results to an average. I'm really struggling to get the text under the slider to behave as I want:
I have managed to get the arrow, percentage, and text to be centered correctly as in the first two images, but when I set the position too high or low, the text overflows into another area of the page. What I want is behaviour like the last two images, where the text stays within its bounds.
I've tried two different ways with the same end result, and now I'm stuck:
<div style="`margin-left:${areaScore}%;margin-right:${100 - areaScore}%;text-align:center`">
<div style="transform: translateX(-50%)" >^</div>
<div style="transform: translateX(-50%); width: 50px">
{{ areaScore }}%
</div>
<div style="transform: translateX(-50%); width: 150px">
The average in your area
</div>
</div>
<div style="position: relative; text-align: center">
<div :style="`position:absolute;left:${areaScore}%`">^</div>
<div :style="`position:absolute;left:${areaScore}%;top:10px`">
{{ areaScore }}%
</div>
<div :style="`position:absolute;left:${areaScore}%;top:24px`">
The average in your area
</div>
</div>
I should probably mention that I'm using Vue, hence the moustaches, colon before style, and parameterisation of areaScore, but I don't think it's particularly relevant to my problem.
I'm sure this problem is solvable, but I've wasted so much time trying to find a solution, and I'm hoping someone can point me in the right direction.