In this example, the first and last pip labels are unreadable, because they are centered under their pip.
How is it possible to move the labels to the slider's center, so they don't exceed the container the slider is in?
And: How can I avoid that the pip labels overlap?
var slider = document.getElementById('slider');
var labels = {
1: 'A very long pip label that exceeds the page',
2: 'This one might overlap with another pip label',
3: 'The last one will also hide to the right',
};
noUiSlider.create(slider, {
start: 1,
step: 1,
range: {
'min': 1,
'max': 3
},
pips: {
mode: 'steps',
filter: function (value, type) {
return type === 0 ? -1 : 1;
},
format: {
to: function (value) {
return labels[value];
}
}
}
});
.noUi-marker-horizontal.noUi-marker-large {
height: 10px;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/noUiSlider/14.5.0/nouislider.min.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/noUiSlider/14.5.0/nouislider.min.js"></script>
<div id="slider"></div>