Does the functionality allow doing this? There is an option to create a block of text, and so that it moves in accordance with the position of the scroll, but this is a creep option.
- Add the screen of the desired, examples of your code, what exactly does not work? - kizoso
|
2 answers
You can build something like that on your knee.
let width = 0; const bar = document.getElementById('percent'); const val = document.getElementById('value'); let timer = setInterval(function() { width++; bar.style.width = width + 'px'; val.innerHTML = (width / 3).toFixed(1); if (width > 300) { clearInterval(timer); } }, 20); #scroll { width: 300px; height: 20px; overflow: hidden; border: 1px solid black; position: relative; } #percent { height: 20px; float: left; width: 0px; background-color: green; } #some-text { position: absolute; } <div id="scroll"> <div id="percent"></div> <span id="some-text"><span id="value"></span>%</span> <div> |
If jquery-plugins to track the scroll. Look, maybe the ScrollSpy plugin from bootstrap will do.
|